httpAgentOptions
在 18 之前的 Node.js 版本中,Next.js 自动用 undici 填充 fetch()
,并默认启用 HTTP 保持活动状态。
¥In Node.js versions prior to 18, Next.js automatically polyfills fetch()
with undici and enables HTTP Keep-Alive by default.
要对服务器端的所有 fetch()
调用禁用 HTTP Keep-Alive,请打开 next.config.js
并添加 httpAgentOptions
配置:
¥To disable HTTP Keep-Alive for all fetch()
calls on the server-side, open next.config.js
and add the httpAgentOptions
config:
module.exports = {
httpAgentOptions: {
keepAlive: false,
},
}