I am developing a web app which fetches data from a backend API server. Most of the times, this is successful. Sometimes the preflight request fails with the following error -
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://<some-backend-server>. (Reason: CORS request did not succeed). Status code: (null).
This issue is only observed on Firefox and not on other browsers. And typically only seen when my laptop starts after going to sleep. Another thing I noticed is that on browser console in network tab, when I switch to raw request headers, all the requests to the above endpoint which are successful shows up like this -
OPTIONS /<endpoint> HTTP/1.1
.
Whereas all the requests that fail show up like this -
OPTIONS /<endpoint> undefined
Edit 1 - Further investigation of backend proxy logs suggest that when the request is failing, the call is not reaching backend at all.
I am developing a web app which fetches data from a backend API server. Most of the times, this is successful. Sometimes the preflight request fails with the following error -
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://<some-backend-server>. (Reason: CORS request did not succeed). Status code: (null).
This issue is only observed on Firefox and not on other browsers. And typically only seen when my laptop starts after going to sleep. Another thing I noticed is that on browser console in network tab, when I switch to raw request headers, all the requests to the above endpoint which are successful shows up like this -
OPTIONS /<endpoint> HTTP/1.1
.
Whereas all the requests that fail show up like this -
OPTIONS /<endpoint> undefined
Edit 1 - Further investigation of backend proxy logs suggest that when the request is failing, the call is not reaching backend at all.
As the issue is only observed on Firefox, it may be imposing a strict same-origin-policy, I think the fix for this will be to enable CORS in the angular application.
you may refer to this thread