我有一个由nginx代理的nextjs项目。我正在使用由nextjs本身提供的rest,它需要超过2分钟。
我得到的第一个错误是nginx的504超时,所以我添加了一些附加指令:
proxy_connect_timeout 600s;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;然后,错误码变成502。查看proxy_error_log文件时,错误是
upstream prematurely closed connection while reading response header from upstream.在我的项目中,我没有显式地使用express或任何其他服务器,所以我不知道如何设置http服务器超时。是否可以为节点js从next.config.js文件或全局设置超时?
发布于 2020-11-13 07:17:13
来自https://github.com/vercel/next.js/discussions/11920#discussioncomment-106683的回答
...this问题只发生在node12中,而不发生在node14中。这是因为node12中的默认超时时间是2分钟,而node14中没有超时。
在next.js中使用node12解决这一问题的唯一方法是通过类似于NODE_OPTIONS='--http-server-default-timeout=0' next start的方法使用--http-server-default-timeout
希望这对任何人都有帮助
https://stackoverflow.com/questions/61007941
复制相似问题