fix: honor proxy env vars in web search HTTP calls#228
Open
serhiizghama wants to merge 2 commits into
Open
Conversation
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.
Problem
The web search pipeline's HTTP calls (Tavily search/extract, Serper search/scrape, SearXNG, Firecrawl, Jina and Cohere rerankers) go through
axioswithout any proxy handling. In corporate/enterprise deployments where outbound traffic must pass through a forward proxy, these calls bypass the proxy and fail with502:Reported in danny-avila/LibreChat#13483. Notably, axios' built-in env-var proxy support doesn't help here because it does not establish a CONNECT tunnel for HTTPS targets — the standard workaround is
HttpsProxyAgentwith axios' own proxy handling disabled (proxy: false), which the reporter verified works in their environment.Solution
getAxiosProxyOptions(url)helper insrc/tools/search/proxy.ts:PROXYvariable first — same convention as the existingHttpsProxyAgentusage inToolSearch,CodeExecutor, andBashExecutorHTTPS_PROXY/HTTP_PROXY/NO_PROXYvariables viaproxy-from-env, so self-hosted endpoints (SearXNG, Firecrawl) can be excluded withNO_PROXYexactly like MCP connections already allowhttps:URLs — plain-HTTP targets keep axios' default behavior, which handles HTTP proxying correctlysrc/tools/search/https-proxy-agentwas already a dependency;proxy-from-envis added (it's tiny and already in the tree as an axios dependency)Testing
npx jest src/tools/search/— 56 tests pass, including new coverage for: no-proxy default,PROXYprecedence overHTTPS_PROXY, empty-string handling,NO_PROXYexclusions, and non-HTTPS passthroughnpx tsc --noEmitandnpx eslintclean,npm run buildsucceedsCloses danny-avila/LibreChat#13483 (the affected code lives here).