I am trying to send post data using this code
axios
.post(
data.submissionUrl,
{ data: sendData },
{ headers: { "Access-Control-Allow-Origin": "*" } }
)
.then((response) => {
console.log(response);
})
.catch((err) => {
console.log(err, err.response);
});
and I am getting this error
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.
however I don't know for what reason if I swap data and headers places the headers are joined with data and the post goes through but the data is incorrect. data: "{"headers":{"Access-Control-Allow-Origin"