【问题标题】:nextjs configure to avoid http server timeoutnextjs 配置避免http服务器超时
【发布时间】:2020-07-15 09:21:47
【问题描述】:

我有一个由 nginx 代理的 nextjs 项目。我正在使用由 nextjs 本身提供的 rest api,需要超过 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 服务器超时。有什么方法可以从 next.config.js 文件或全局节点 js 设置超时?

【问题讨论】:

  • 可能有任何更新吗?如果您找到了解决方案,请您回答您自己的问题,我支持它。

标签: next.js


【解决方案1】:

secret104278的回答:

...这个问题只出现在 node12 中,而不出现在 node14 中。这是因为 node12 中的默认超时为 2 分钟,而 node14 中没有超时

在 next.js 中使用 node12 解决此问题的唯一方法是使用 --http-server-default-timeout NODE_OPTIONS='--http-server-default-timeout=0' next start 之类的东西

希望对大家有所帮助

【讨论】:

    猜你喜欢
    • 2015-09-15
    • 1970-01-01
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 2013-07-15
    • 2020-06-12
    • 1970-01-01
    相关资源
    最近更新 更多