跳到内容
配置next.config.jshttpAgentOptions

httpAgentOptions

在 18 之前的 Node.js 版本中,Next.js 使用 undici 自动填充 fetch(),并默认启用 HTTP Keep-Alive

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

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