From e4d344d49f038d0e427824e608e3b725a3f3bb6d Mon Sep 17 00:00:00 2001 From: Long Zheng Date: Fri, 25 Nov 2022 21:47:58 +1100 Subject: [PATCH 1/3] Update disabling-http-keep-alive.md for server-side only Fixes https://github.com/vercel/next.js/issues/43354 It is not possible to specify an `agent` on a single `fetch()` call since the types for `fetch` come from TypeScript where `agent` is not supported as an option. --- .../next.config.js/disabling-http-keep-alive.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/docs/api-reference/next.config.js/disabling-http-keep-alive.md b/docs/api-reference/next.config.js/disabling-http-keep-alive.md index bfa79ad3d8b6def..9f9870e2e127d5e 100644 --- a/docs/api-reference/next.config.js/disabling-http-keep-alive.md +++ b/docs/api-reference/next.config.js/disabling-http-keep-alive.md @@ -4,19 +4,9 @@ description: Next.js will automatically use HTTP Keep-Alive by default. Learn mo # Disabling HTTP Keep-Alive -Next.js automatically polyfills [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. You may want to disable HTTP Keep-Alive for certain `fetch()` calls or globally. +Next.js automatically polyfills `fetch()` in the Node.js environment with [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. -For a single `fetch()` call, you can add the agent option: - -```js -import { Agent } from 'https' - -const url = 'https://example.com' -const agent = new Agent({ keepAlive: false }) -fetch(url, { agent }) -``` - -To override all `fetch()` calls globally, you can use `next.config.js`: +To disable HTTP Kee-Alive for all `fetch()` calls on the server-side, open `next.config.js` and add the `httpAgentOptions` config: ```js module.exports = { From 323275797585b9778be4bb774968bdb0fe0ce9bb Mon Sep 17 00:00:00 2001 From: Long Zheng Date: Fri, 25 Nov 2022 22:15:21 +1100 Subject: [PATCH 2/3] Fix typo and lint --- .../api-reference/next.config.js/disabling-http-keep-alive.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-reference/next.config.js/disabling-http-keep-alive.md b/docs/api-reference/next.config.js/disabling-http-keep-alive.md index 9f9870e2e127d5e..54e103cf9e275ca 100644 --- a/docs/api-reference/next.config.js/disabling-http-keep-alive.md +++ b/docs/api-reference/next.config.js/disabling-http-keep-alive.md @@ -4,9 +4,9 @@ description: Next.js will automatically use HTTP Keep-Alive by default. Learn mo # Disabling HTTP Keep-Alive -Next.js automatically polyfills `fetch()` in the Node.js environment with [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. +Next.js automatically polyfills `fetch()` in the Node.js environment with [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. -To disable HTTP Kee-Alive for all `fetch()` calls on the server-side, open `next.config.js` and add the `httpAgentOptions` config: +To disable HTTP Keep-Alive for all `fetch()` calls on the server-side, open `next.config.js` and add the `httpAgentOptions` config: ```js module.exports = { From 4063e58689452382afc09ed08d486633bcd349c9 Mon Sep 17 00:00:00 2001 From: Long Zheng Date: Sat, 17 Dec 2022 13:07:05 +1100 Subject: [PATCH 3/3] Update docs/api-reference/next.config.js/disabling-http-keep-alive.md Co-authored-by: Steven --- docs/api-reference/next.config.js/disabling-http-keep-alive.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-reference/next.config.js/disabling-http-keep-alive.md b/docs/api-reference/next.config.js/disabling-http-keep-alive.md index 54e103cf9e275ca..21fb2be489ee129 100644 --- a/docs/api-reference/next.config.js/disabling-http-keep-alive.md +++ b/docs/api-reference/next.config.js/disabling-http-keep-alive.md @@ -4,7 +4,7 @@ description: Next.js will automatically use HTTP Keep-Alive by default. Learn mo # Disabling HTTP Keep-Alive -Next.js automatically polyfills `fetch()` in the Node.js environment with [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. +In Node.js versions prior to 18, Next.js automatically polyfills `fetch()` with [node-fetch](/docs/basic-features/supported-browsers-features#polyfills) and enables [HTTP Keep-Alive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive) by default. To disable HTTP Keep-Alive for all `fetch()` calls on the server-side, open `next.config.js` and add the `httpAgentOptions` config: