我部署了一个节点/express api (api.mysite.com)
在express应用中,我使用了app.use(cors());
在前端,我有一个nuxt/vue站点(www.mysite.com)。
vue站点使用api来获取一些数据。问题是,大多数情况下,它工作得很好。但有时(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.我读了很多书,但我不明白为什么它会特别发生,为什么只是偶尔发生,而不是其他时候?
发布于 2019-03-23 20:41:51
将超时设置为更高的值。如果处理请求的时间超过当前超时,则会抛出网关超时
var server= http.createServer(app).listen(port, function()
{
console.log("Listening on port " + port)
})
server.timeout = 240000;https://stackoverflow.com/questions/54740174
复制相似问题