J
J
JavaSscriptNoob2021-10-24 12:26:36
CORS
JavaSscriptNoob, 2021-10-24 12:26:36

How to get rid of cors error response to preflight request doesn't pass access control check: It does not have HTTP ok status.?

I send a request like this with headers like this:

return fetch(url, {
      headers: {
        'Authorization': `Bearer eyJhbGciOiJIUzI1NiJ9.eyJ2zdWIiOiIyMDQ4NTU4ODAiLCJpYXQiOjE2MfazUwNjMwNzksImV4cCI6MTY0MzcwMzA3OX0.vA7WaN2Ep2fmGOVbZPt7Rw7gwt0msKyylzrKkh7dLOxB0`,
        'accept': "*/*",
      },
    });
  }

In response, I get the error response to preflight request doesn't pass access control check: It does not have HTTP ok status.?
The error started appearing after adding the Authorization header, before that everything was ok.
The same requests but from a postman or heroku pass with a bang, what could be the problem?
I can also add that when sending a request, it is not clear where another options request is hung from

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2021-10-24
@JavaSscriptNoob

Most likely the server is not able to process OPTION request. Postman and node don't care about the same origin policy, so they don't try to send an OPTION request.
Please include the answer from the server in your question, then it will be possible to give a more accurate answer.
Yes, unlike chrome, firefox in the developer console shows you both requests, open the network tab and take a screenshot here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question