fix: assume http/https scheme for scheme-less proxy env vars#4914
Open
travisbreaks wants to merge 2 commits intonodejs:mainfrom
Open
fix: assume http/https scheme for scheme-less proxy env vars#4914travisbreaks wants to merge 2 commits intonodejs:mainfrom
travisbreaks wants to merge 2 commits intonodejs:mainfrom
Conversation
When HTTP_PROXY or HTTPS_PROXY env vars (or httpProxy/httpsProxy options) are set without a URL scheme (e.g. "localhost:8080" instead of "http://localhost:8080"), EnvHttpProxyAgent now prepends the appropriate scheme rather than passing the value verbatim to ProxyAgent, which would fail on URL parsing. HTTP_PROXY values default to http://, and HTTPS_PROXY values default to https://. This matches the behavior of curl and Go's httpproxy package. Values that already have a scheme are left unchanged. Fixes: nodejs#4736 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4914 +/- ##
==========================================
- Coverage 92.92% 92.91% -0.01%
==========================================
Files 112 112
Lines 35646 35668 +22
==========================================
+ Hits 33123 33141 +18
- Misses 2523 2527 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4736.
When
HTTP_PROXYorHTTPS_PROXYenvironment variables (or thehttpProxy/httpsProxyconstructor options) are set without a URL scheme (e.g.localhost:8080instead ofhttp://localhost:8080),EnvHttpProxyAgentnow prepends the appropriate scheme before passing the value toProxyAgent.HTTP_PROXY/httpProxyvalues default tohttp://HTTPS_PROXY/httpsProxyvalues default tohttps://http://,https://,socks5://) are unchangedThis matches the behavior of curl and Go's httpproxy package, which both assume
http://for scheme-less proxy values. The split behavior (http://for HTTP_PROXY,https://for HTTPS_PROXY) was requested by a maintainer in #4860 (comment) and aligns with what curl does.Changes
normalizeProxyUrl()helper inlib/dispatcher/env-http-proxy-agent.jsTest plan
test/env-http-proxy-agent.jspass (34 existing + 6 new)