Skip to content

http: use env proxy when agent has no proxyEnv option#64528

Open
swigger wants to merge 1 commit into
nodejs:mainfrom
swigger:http-agent-use-env-proxy
Open

http: use env proxy when agent has no proxyEnv option#64528
swigger wants to merge 1 commit into
nodejs:mainfrom
swigger:http-agent-use-env-proxy

Conversation

@swigger

@swigger swigger commented Jul 16, 2026

Copy link
Copy Markdown

When a user creates a custom agent without specifying proxyEnv but Node.js is configured to use a proxy from the environment (via --use-env-proxy or NODE_USE_ENV_PROXY), fall back to process.env.

A developer can still explicitly disable proxying for an agent even when Node.js is configured to use a proxy at runtime, by passing a falsy proxyEnv explicitly. For example:

const agent = new https.Agent({ proxyEnv: null });

When a user creates a custom agent without specifying proxyEnv but
Node.js is configured to use a proxy from the environment (via
--use-env-proxy or NODE_USE_ENV_PROXY), fall back to process.env.

A developer can still explicitly disable proxying for an agent even
when Node.js is configured to use a proxy at runtime, by passing a
falsy proxyEnv explicitly. For example:

    const agent = new https.Agent({ proxyEnv: null });

Signed-off-by: swigger <[email protected]>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Jul 16, 2026
@mcollina mcollina requested a review from joyeecheung July 16, 2026 13:40

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening a PR! Can you please add a unit test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants