-1

I use React and Axios for API consumption. When I try to append an endpoint I get this error:

'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status

But in Postman the endpoint works. In most of the solutions that I found on the net the problem is solved on the backend side. Unfortunately I do not have access to the backend. What can I do to solve the problem on the frontend side?

My request:

axios.post(`http://15.70.227.30:8345/my_api/login/`,
      {
        username: testApi, 
        password: 123456
      })
      .then((res) => return res)
      .catch((err) => return err );
jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
Veron
  • 1
  • 4
  • 1
    You can't solve it on the front-end. This is a policy followed by all browsers, that's why it works in postman and not in the the browser. – super May 24 '22 at 07:36
  • CORS wouldn't be very useful if Site A could use it to tell the browser that Site A's JavaScript should be allowed access to Site B's data (with the browser owner's cookies and ip address). – Quentin May 24 '22 at 07:45

0 Answers0