Answer the question
In order to leave comments, you need to log in
Why CORS instead of a response in case of failure, although in case of success the response reaches?
I send via Axios (or jQuery Ajax, it doesn't matter) a POST request to the server.
If the server response is successful (status code 200), then the response comes, everything is fine.
If the server response is unsuccessful (any status error code, 400, 404, etc.), then the response does not reach the client, instead a CORS error.
Why CORS? After all, successful responses reach the client...
In the server configuration, I specified:
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept, Authorization";
add_header "Access-Control-Request-Methods" "GET, POST, OPTIONS";
Answer the question
In order to leave comments, you need to log in
As I understand it myself, when sending a request from JS to another server, in case of a status other than 200, there will always be a CORS error and nothing else.
It is necessary to raise a layer (proxy) on the same server and send requests and issue answers through it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question