fix(utils/request-rewriter): pass CONNECT proxy tunnel requests through untouched - #23136
Open
ryanchou1994 wants to merge 1 commit into
Open
ryanchou1994 wants to merge 1 commit into
ryanchou1994 wants to merge 1 commit into
Conversation
…gh untouched tunnel-agent (used by request / request-promise, e.g. instagram-private-api with IG_PROXY) sends a CONNECT request with legacy options whose path is the tunnel target authority (host:port), not a URL path. Rebuilding a URL from those options produced http://127.0.0.1i.instagram.com:443/ and node then resolved that bogus hostname (ENOTFOUND). Hand CONNECT requests to node as-is: they cannot be turned into a URL, and UA/referer/proxy-agent injection does not apply to a proxy handshake. Fixes DIYgod#16970
Contributor
Author
|
Gentle ping — also open for two weeks. All checks are green here (the Vercel one is just the preview auth page, not a build failure). The change keeps CONNECT tunnel requests untouched so proxied requests stop getting mangled by the rewriter. Let me know if you want anything changed. |
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.
Involved Issue / 该 PR 相关 Issue
Close #16970
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明
With
IG_PROXYset, instagram-private-api usesrequest+ tunnel-agent, which sends aCONNECTto the proxy with legacy options whosepathis the tunnel target (i.instagram.com:443), not a URL path. The rewriter rebuilds a URL as protocol + host + path, givinghttp://127.0.0.1i.instagram.com:443/, and node fails withENOTFOUND 127.0.0.1i.instagram.com.Fix: in the legacy options branch, hand
CONNECTrequests to node untouched. A URL cannot be rebuilt for them, and UA / referer injection is meant for the target site, not the proxy handshake. CONNECT requests thus no longer get the global proxy agent; that path has never worked since 2024-03, so nothing depends on it. Regular requests are unaffected. Unlike the workaround in the issue, this does not throw on options without a port and keeps tunnel-agent'sagent: false.Tests: two cases added to the get wrapper tests (a normal legacy options request and the tunnel-agent CONNECT shape). With the fix reverted the CONNECT case fails with the malformed URL above; with it the suite passes 15/15 on node 24; oxlint, oxfmt and tsc are clean. No Instagram account plus HTTP proxy here, so the end-to-end login flow was not run.