fix(proxy): honor HTTP(S)_PROXY when downloading media - #2224
Open
andersonlemesc wants to merge 1 commit into
Open
fix(proxy): honor HTTP(S)_PROXY when downloading media#2224andersonlemesc wants to merge 1 commit into
andersonlemesc wants to merge 1 commit into
Conversation
andersonlemesc
force-pushed
the
fix/proxy-media-download
branch
from
August 14, 2026 12:20
ff75e17 to
91cb2fe
Compare
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
On a host with no direct internet egress, where all outbound HTTP(S) traffic has to go through a proxy, every incoming media message fails to download. The webhook is delivered with
hasMedia: trueandmedia.url: null, and the logs show:WHATSAPP_PROXY_SERVERdoes not cover this: it builds anHttpsProxyAgentfor the Baileys socket, while media is fetched through Node's globalfetch, which uses undici and ignores that agent.Node's
NODE_USE_ENV_PROXY=1does not help either, becausesrc/main.tsreplaces the global dispatcher during bootstrap:That call discards the proxy-aware dispatcher installed from the environment, so
fetchgoes out direct and fails.Fix
Keep the IPv4 pinning, but pick a proxy-aware dispatcher when proxy variables are present.
EnvHttpProxyAgent(undici >= 6.20, and this repo is on ^7.16) readshttp_proxy/https_proxyand honorsNO_PROXY, so internal hosts such as S3 storage and webhook targets keep going direct.With no proxy variables set, behavior is identical to today.
Testing
Verified on a proxy-only network with the NOWEB engine: without the change every media download fails with the error above; with it,
MediaManagerlogsThe media from '<id>' has been saved.and the webhook carries a workingmedia.url. S3 uploads to an internal endpoint listed inNO_PROXYstill go direct.