How to fix CORS + failed to load resource: net::err_failed happening only in the first request
I have a frontend and backend both deployed on Azure app service.
The problem is the first request from the FE to the BE after some inactive time usually fails with the following errors,
The backend app logs don't show anything, it seems like the request didn't reach the backend. So maybe the backend is sleeping because of the inactivity? But why do we get the CORS error? I have configured CORS for the backend. To fix the sleeping issue, I have turned on the AlwaysOn feature and also added an availability ping that checks the health of the backend every 15 minutes, I thought that should make it available all the time.
Although the health pings are successful all the time, this request( which is much heavier than the health pings, involves sending images and detection using a model, and takes a fairly long time ) always fails on the first try and succeeds on subsequent requests.
Can someone help me with this?
Thanks in advance.