From bedaaa11fc07ee220e6dde457050c2dbb4931ace Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 20 Mar 2025 15:35:05 +0100 Subject: [PATCH] http: support http proxy for fetch under NODE_USE_ENV_PROXY When enabled, Node.js parses the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables during startup, and tunnels requests over the specified proxy. This currently only affects requests sent over `fetch()`. Support for other built-in `http` and `https` methods is under way. PR-URL: https://github.com/nodejs/node/pull/57165 Refs: https://github.com/nodejs/undici/issues/1650 Reviewed-By: Matteo Collina --- doc/api/cli.md | 15 ++++ doc/node.1 | 13 +++ lib/internal/process/pre_execution.js | 16 ++++ test/common/proxy-server.js | 100 ++++++++++++++++++++++++ test/fixtures/fetch-and-log.mjs | 3 + test/parallel/test-http-proxy-fetch.js | 61 +++++++++++++++ test/parallel/test-https-proxy-fetch.js | 67 ++++++++++++++++ 7 files changed, 275 insertions(+) create mode 100644 test/common/proxy-server.js create mode 100644 test/fixtures/fetch-and-log.mjs create mode 100644 test/parallel/test-http-proxy-fetch.js create mode 100644 test/parallel/test-https-proxy-fetch.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 73d8fb3191e..7e13d277667 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -3629,6 +3629,21 @@ If `value` equals `'0'`, certificate validation is disabled for TLS connections. This makes TLS, and HTTPS by extension, insecure. The use of this environment variable is strongly discouraged. +### `NODE_USE_ENV_PROXY=1` + + + +> Stability: 1.1 - Active Development + +When enabled, Node.js parses the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` +environment variables during startup, and tunnels requests over the +specified proxy. + +This currently only affects requests sent over `fetch()`. Support for other +built-in `http` and `https` methods is under way. + ### `NODE_USE_SYSTEM_CA=1`