httpAgentOptions
在 Node.js 18 之前的版本中,Next.js 会自动用 undici polyfill fetch(),并默认启用 HTTP Keep-Alive。
要为服务端所有 fetch() 调用禁用 HTTP Keep-Alive,请在 next.config.js 中添加 httpAgentOptions 配置:
next.config.js
module.exports = {
httpAgentOptions: {
keepAlive: false,
},
}