introduction
Next.js 自动的填充了node-fetch 并默认启用了 HTTP Keep-Alive …
你可能想要禁用长连接(对于某些调用)或者全局性的禁用 …
对于单个fetch调用,你能够增加agent 选项
import { Agent } from 'https'const url = 'https://example.com'const agent = new Agent({ keepAlive: false })fetch(url, { agent })
为了覆盖所有的fetch调用,你能够使用next.config.js配置
module.exports = {httpAgentOptions: {keepAlive: false,},}
