fix(env-http-proxy-agent): NO_PROXY wildcard semantics - #5777
Open
mcollina wants to merge 1 commit into
Open
Conversation
Make `*.domain` NO_PROXY entries match subdomains only, not the apex host (align with node:http and the usual wildcard convention), and recognize a bare '*' entry as a global wildcard regardless of its position or surrounding whitespace (e.g. ' * ' or 'none.invalid,*'). Previously these bypassed the proxy incorrectly or not at all. Refs: nodejs/node#57872
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5777 +/- ##
==========================================
+ Coverage 93.50% 93.51% +0.01%
==========================================
Files 110 110
Lines 39072 39374 +302
==========================================
+ Hits 36534 36821 +287
- Misses 2538 2553 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
inoway46
reviewed
Sep 6, 2026
Comment on lines
+103
to
+108
| if (entry.hostname === '*') { | ||
| if (entry.port && entry.port !== port) { | ||
| continue | ||
| } | ||
| return false // Never proxy if a wildcard entry is present. | ||
| } |
There was a problem hiding this comment.
I noticed this also introduces *:PORT behavior, while node:http currently only treats an exact * entry as a global wildcard.
Is that difference intentional given the goal of keeping the two implementations consistent?
If *:PORT is intended here, it might also be worth adding coverage for the non-matching-port case.
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.
Fix NO_PROXY wildcard matching in
EnvHttpProxyAgentsofetch()is internally consistent withnode:http(seenodejs/node#57872, theNO_PROXYdifferences table).Three non-sensible behaviors are fixed:
*.example.compreviously bypassed the proxy for the apexexample.comitself. A*.domainentry is a subdomain wildcard and must only matchsub.example.com/a.b.example.com, not the apex.node:httpalready does this.*(a wildcard with surrounding whitespace) was not recognized as a global wildcard because the check compared the wholeNO_PROXYstring against*.none.invalid,*(a*among other entries) was likewise not recognized as a global wildcard.A bare
*entry now matches all hosts regardless of position or whitespace, and is port-aware (*:80only bypasses that port).Tests updated and added; all
env-http-proxy-agenttests pass and lint is clean.Refs: nodejs/node#57872