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,
  },
}