Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

504 (Gateway Time-out) issue

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?

like image 213
asanas Avatar asked Dec 02 '25 05:12

asanas


1 Answers

Set the timeout to a higher value. If your request is taking more time to be served than the current timeout it throws Gateway Timeout

var server= http.createServer(app).listen(port, function()
{
    console.log("Listening on port " + port)
})
server.timeout = 240000;
like image 60
Amstel D'Almeida Avatar answered Dec 03 '25 19:12

Amstel D'Almeida



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!