Axios cors error when post
I am. trying to upload a image to my unsign preset using axios post request on my react app. I am getting CORS error. Any advice and help is appreciated
const img = event.target.files[0];
const data = new FormData();
data.append("file", img);
data.append("upload_preset", "SECRET_PRESET");
The error i get back is
await axios
.post("https://api.cloudinary.com/v1_1/CLOUDNAME/image/upload/", data)
.then((res) => {
console.log("response");
console.log(res);
})
.catch((err) => console.log(err));
Access to XMLHttpRequest at 'https://api.cloudinary.com/v1_1/CLOUDNAME/image/upload/' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field x-access-token is not allowed by Access-Control-Allow-Headers in preflight response.
1
-
Hi Victor,
This could be related to the Axios where you will need to create an instance without the interceptors as described in this link.
Hope this helps.
0
Post is closed for comments.
Comments
1 comment