跳到主要內容
設定next.config.jshttpAgentOptions

httpAgentOptions

在 18 之前的 Node.js 版本中,Next.js 會使用 undici 自動 polyfill fetch(),並預設啟用 HTTP Keep-Alive

若要停用伺服器端所有 fetch() 呼叫的 HTTP Keep-Alive,請開啟 next.config.js 並新增 httpAgentOptions 設定

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