我正在尝试使用此代码发送帖子数据
axios
.post(
data.submissionUrl,
{ data: sendData },
{ headers: { "Access-Control-Allow-Origin": "*" } }
)
.then((response) => {
console.log(response);
})
.catch((err) => {
console.log(err, err.response);
});
我收到了这个错误
Access to XMLHttpRequest at 'https://website' from origin 'vscode live server' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
但是我不知道如果我交换数据和标题将标题与数据连接并且帖子通过但数据不正确的原因是什么。data: "{"headers":{"Access-Control-Allow-Origin"