我使用axios从我的web前端向第三方api发出了以下post请求,但它无法通过。
Axios({
method: 'post',
url: 'https://some.website.com/oauth/token',
data: {
client_secret: 'revmisodtoire43-00j232onfkdl',
code: '54728349765905473289',
grant_type: 'authorization_code'
}
})
.then(res => {
console.log('client info: ', res);
});错误显示:Failed to load https://some.website.com/oauth/token: Response for preflight is invalid,然后是network error。
当我通过curl发出同样的请求时,它没有任何问题。
我知道这与CORS相关,但不确定如何处理它。有什么建议吗?
发布于 2017-12-14 13:15:11
检查是否在标头中添加了content-type,如果没有,请尝试在请求标头中添加'Access-Control-Allow-Origin':'*‘
https://stackoverflow.com/questions/47806165
复制相似问题