I have a node/express api deployed (api.mysite.com)
In the express app, I have used app.use(cors());
In the frontend I have a nuxt/vue site (www.mysite.com).
The vue site uses the api to fetch some data. The problem is that most times it works fine. But some times (2 out of 10), I get the following error:
Failed to load resource: the server responded with a status of 504 (Gateway Time-out)
Access to XMLHttpRequest at 'api.mysite.com' from origin 'www.mysite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I've read a lot but cannot figure out why it's happening specially why only sometimes and not the other times?