跳至內容

HTTP 代理選項 (httpAgentOptions)

在 Node.js 18 之前的版本中,Next.js 會自動使用 undicifetch() 進行 polyfill,並預設啟用 HTTP Keep-Alive 持續連線

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

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