2

I'm using an Axios module in my React app, and I am using to API POST method.

Like this:

axios.request({
    method: "POST",
    url,
    responseType: "jsonp",
    data: payload,
    ...config
});

But I get an error:

Access to XMLHttpRequest at 'http://0.0.0.0/api/ak' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. xhr.js:160 POST http://0.0.0.0/api/ak net::ERR_FAILED

Where am I wrong?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rohit Azad Malik
  • 31,410
  • 17
  • 69
  • 97

1 Answers1

-1

Setup package CORS in your Express server

https://www.npmjs.com/package/cors

Sangam Rajpara
  • 652
  • 3
  • 12