I am trying to doing a post request by passing "X-CSRF-TOKEN" into the headers i am getting this error Request header field x-csrf-token is not allowed by Access-Control-Allow-Headers in preflight response. Below is my code.
const headers = {
"Content-Type": "application/json",
"X-CSRF-TOKEN": "g3DW38GFNJoUd9krAYwU8855GZs_fRfEPFFF9aJNLgI",
"Access-Control-Allow-Headers":
"Origin, X-Requested-With, Content-Type, Accept, Authorization,X-Auth-Token, X-CSRF-TOKEN",
"Access-Control-Allow-Origin": "http://localhost:3000",
"Access-Control-Allow-Credentials":"true"*
};
axios
.post(url,data,{ headers: headers })
.then((res) => {
console.log("response", res);
})
.catch((err) => {
console.log(err);
});