简体   繁体   English

504(网关超时)问题

[英]504 (Gateway Time-out) issue

I have a node/express api deployed (api.mysite.com)我部署了一个节点/express api (api.mysite.com)

In the express app, I have used app.use(cors());在快递应用中,我使用了 app.use(cors());

In the frontend I have a nuxt/vue site (www.mysite.com).在前端,我有一个 nuxt/vue 站点 (www.mysite.com)。

The vue site uses the api to fetch some data. vue 站点使用 api 来获取一些数据。 The problem is that most times it works fine.问题是大多数时候它工作正常。 But some times (2 out of 10), I get the following error:但有时(10 次中有 2 次),我收到以下错误:

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?我读了很多,但无法弄清楚为什么会发生这种情况,为什么只有有时而不是其他时间?

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM