5Xx or 4Xx Error with "No 'Access-Control-Allow-Origin' Header Is Present"

“No 'Access-Control-Allow-Origin' header is present” error for some requests but not others

Any time you run into a case where you’re seeing a “No 'Access-Control-Allow-Origin' header is present” message for some requests but not others, use the Network pane in browser devtools to check the HTTP status code of the response.

Almost always what you’re going to find is that the HTTP status code in those cases is a 4xx or 5xx error instead of the expected 200 OK success response.

The only reason you see the “No 'Access-Control-Allow-Origin' header is present” message is those cases is, the Access-Control-Allow-Origin header typically isn’t going to get added to 4xx and 5xx errors. Part of the reason is, in the 5xx case especially, the cause can be a server failure that occurs before the server ever gets around to running your application code. Along with that, most servers by default won’t add application-set response headers to 4xx and 5xx errors; instead by default they only add them to 2xx success responses.

So anyway, what you want to do is, look at the server logs on the server side (for the server you’re sending the request to) and see what messages the server is logging about the cause of whatever problem it is that makes the server end up sending that 4xx or 5xx error response.

Getting No 'Access-Control-Allow-Origin' header is present on the requested resource from Flask API

I changed GET to POST and all works fine for me, thanks for the answers.

post error in angular 5 No 'Access-Control-Allow-Origin' header is present on the requested resource.

jonrsharpe is right you need to enable CORS but if you need a very fast temporary solution ?

For example you need to give a presentation you can download this chrome extension. https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=chrome-ntp-icon

Getting Error No 'Access-Control-Allow-Origin' header is present on the requested resource. in ionic2

Try again using this plugin in your browser.

It allows to you request any site with ajax from any source, no matter http/https discrepancies and the like. Practically adds the Allow-Control-Allow-Origin: * header in the response.

Please keep in mind that this is a band-aid solution. Your server response has to actually have the 'Access-Control-Allow-Origin': '*' header, preferably with a more specific value than *.

Response had HTTP status code 400 + No 'Access-Control-Allow-Origin' header is present on the requested resource. - MEAN STACK

You can use npm library cors which is much easier cors-npm

you don't need to use express-cors

const allowCors = require('./cors')


Related Topics



Leave a reply



Submit