[英]Post request using axios fails with “Response for preflight is invalid” error
我使用axios从我的Web前端向第三方api发出了以下发布请求,但无法通过。
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有关,但不确定如何处理。 有什么建议么?
检查是否在标头中添加了内容类型,如果不是,请尝试在请求标头中添加以下“ Access-Control-Allow-Origin”:“ *”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.