feat: add HTTP_PROXY/HTTPS_PROXY support#101
Open
draix wants to merge 1 commit intoMiniMax-AI:mainfrom
Open
Conversation
Node.js native fetch() does not respect HTTP_PROXY/HTTPS_PROXY environment variables, preventing users behind corporate proxies from using the CLI. This commit adds a proxy-aware fetch wrapper using undici's ProxyAgent that: - Detects HTTP_PROXY, HTTPS_PROXY, http_proxy, https_proxy env vars - Respects NO_PROXY/no_proxy for bypassing proxy on specific hosts - Supports wildcard patterns in NO_PROXY (e.g., *.internal.com, .local) - Caches the ProxyAgent instance for performance - Falls back to native fetch when no proxy is configured All fetch() calls throughout the codebase have been updated to use proxyFetch(): - src/client/http.ts (main API client) - src/auth/oauth.ts (OAuth token exchange) - src/auth/refresh.ts (token refresh) - src/config/detect-region.ts (region detection) - src/files/download.ts (file downloads) - src/update/checker.ts (update checks) - src/update/self-update.ts (self-update downloads) - src/commands/vision/describe.ts (image fetching) Closes MiniMax-AI#96
Collaborator
|
why need proxy? |
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
Node.js native
fetch()does not respectHTTP_PROXY/HTTPS_PROXYenvironment variables, preventing users behind corporate proxies from using the CLI.This PR adds a proxy-aware fetch wrapper using undici's
ProxyAgentthat transparently routes requests through the configured proxy.Changes
New module:
src/client/proxy.tsA centralized proxy-aware fetch function that:
HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxyenv varsNO_PROXY/no_proxyfor bypassing proxy on specific hosts*.internal.com,.local)ProxyAgentinstance for performancefetchwhen no proxy is configuredUpdated files
All
fetch()calls throughout the codebase have been updated to useproxyFetch():src/client/http.ts(main API client)src/auth/oauth.ts(OAuth token exchange)src/auth/refresh.ts(token refresh)src/config/detect-region.ts(region detection)src/files/download.ts(file downloads)src/update/checker.ts(update checks)src/update/self-update.ts(self-update downloads)src/commands/vision/describe.ts(image fetching)Dependencies
Added
undicias a dependency. While Node.js uses undici internally for its nativefetch, theProxyAgentAPI is not exposed through the globalfetch. The undici package provides the necessaryProxyAgentclass to enable proxy support.Tests
Added tests in
test/client/proxy.test.tscovering:Usage
Users can now configure proxy settings via environment variables:
Closes #96