NNext.js 中文网 GitHub

httpAgentOptions

Next.js 默认会自动使用 HTTP Keep-Alive。在此了解如何禁用 HTTP Keep-Alive。

在 18 之前的 Node.js 版本中,Next.js 会使用 undici自动为 fetch() 提供 polyfill,并默认启用 HTTP Keep-Alive。

要为服务器端的所有 fetch() 调用禁用 HTTP Keep-Alive,请打开 next.config.js 并添加 httpAgentOptions 配置:

next.config.js
module.exports = {
  httpAgentOptions: {
    keepAlive: false,
  },
}