Skip to content

fix: handle schema-less HTTP_PROXY env vars#4809

Open
M-YasirGhaffar wants to merge 1 commit intonodejs:mainfrom
M-YasirGhaffar:fix/schema-less-proxy-url
Open

fix: handle schema-less HTTP_PROXY env vars#4809
M-YasirGhaffar wants to merge 1 commit intonodejs:mainfrom
M-YasirGhaffar:fix/schema-less-proxy-url

Conversation

@M-YasirGhaffar
Copy link

This relates to...

Fixes #4736

Rationale

When HTTP_PROXY or HTTPS_PROXY is set without a URL scheme (e.g., localhost:8080 instead of http://localhost:8080), the EnvHttpProxyAgent fails. This PR adds automatic http:// prefix for schema-less proxy URLs, matching Go's httpproxy behavior.

Changes

Added normalizeProxyUrl() helper function in lib/dispatcher/env-http-proxy-agent.js. Also added tests in test/env-http-proxy-agent.js.

Features

N/A

Bug Fixes

  • Schema-less proxy URLs now work by assuming http:// protocol

Breaking Changes and Deprecations

None. This is additive behavior - existing URLs with explicit schemes are unchanged.

Status

  • I have read and agreed to the Developer's Certificate of Origin
  • Tested
  • Benchmarked (optional)
  • [S] Documented
  • Review ready
  • In review
  • Merge ready

Signed-off-by: M-YasirGhaffar <yasirghaffar.nust@gmail.com>
@mcollina
Copy link
Member

mcollina commented Feb 5, 2026

cc @joyeecheung can you take a look as well?

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (fc8bb75) to head (f052510).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4809      +/-   ##
==========================================
- Coverage   93.26%   93.26%   -0.01%     
==========================================
  Files         109      109              
  Lines       34090    34098       +8     
==========================================
+ Hits        31794    31800       +6     
- Misses       2296     2298       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@metcoder95
Copy link
Member

Will this require adjustments in Node for fetch besides the Undici upgrade?

@M-YasirGhaffar
Copy link
Author

@metcoder95 This shouldn't require any changes for fetch. The normalization happens inside EnvHttpProxyAgent before the URL reaches ProxyAgent.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema-less HTTP_PROXY and HTTPS_PROXY env vars should maybe assume http

4 participants