From 9b82f97ee72f8510d8d5a45a33928a2835859bd7 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 21 Jul 2025 19:05:49 +0200 Subject: [PATCH 1/2] cli: add --use-env-proxy This does the same as NODE_USE_ENV_PROXY. When both are set, like other options that can be configured from both sides, the CLI flag takes precedence. --- doc/api/cli.md | 19 +++ doc/api/errors.md | 2 +- doc/api/http.md | 16 ++- doc/node-config-schema.json | 3 + doc/node.1 | 3 + lib/_http_agent.js | 4 +- lib/https.js | 4 +- lib/internal/process/pre_execution.js | 29 +++-- src/node_options.cc | 8 ++ src/node_options.h | 1 + test/client-proxy/test-http-proxy-request.mjs | 2 - .../client-proxy/test-https-proxy-request.mjs | 2 - .../test-use-env-proxy-cli-http.mjs | 75 +++++++++++ .../test-use-env-proxy-cli-https.mjs | 81 ++++++++++++ .../test-use-env-proxy-precedence.mjs | 117 ++++++++++++++++++ test/common/proxy-server.js | 8 +- 16 files changed, 346 insertions(+), 28 deletions(-) create mode 100644 test/client-proxy/test-use-env-proxy-cli-http.mjs create mode 100644 test/client-proxy/test-use-env-proxy-cli-https.mjs create mode 100644 test/client-proxy/test-use-env-proxy-precedence.mjs diff --git a/doc/api/cli.md b/doc/api/cli.md index 6778d3db33bf53..38192350b4c308 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2999,6 +2999,20 @@ environment variables. See `SSL_CERT_DIR` and `SSL_CERT_FILE`. +### `--use-env-proxy` + + + +> 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 is equivalent to setting the [`NODE_USE_ENV_PROXY=1`][] environment variable. + ### `--use-largepages=mode`