所以我有一个http GET请求:http://localhost:8080/api/toptracks
.
我安装了 koa-cors 软件包并将 cors 设置为:
app.use(cors({
origin: 'http://localhost:3000'
}));
Axios 调用只是一个简单的axios.get(url).then(..)
但它只在 Chrome 中返回,而不是在 Firefox 中返回,网络选项卡显示类似 DNS resolution
,我清除了缓存。
有没有人知道如何解决它?
设法
使用解决方案修复:
axios({
method: 'GET',
url: 'http://localhost:8080/api/track/toptracks?limit=250',
headers: {
'Content-Type': 'application/json'
},
json: true
})