Support HTTP_PROXY/HTTPS_PROXY/NO_PROXY
Author: mhioCreated Oct 13, 2025Updated Jul 24, 2026
Labelsfeature
Please avoid duplicates
- I checked all open feature requests and none of them matched my request.
Context
Node now supports HTTP_PROXY/HTTPS_PROXY/NO_PROXY natively via NODE_USE_ENV_PROXY=1 and --use-env-proxy PR https://github.com/nodejs/node/pull/58980
There's three modes I can immediately think of that might be needed globally or per test.
- Use ENV config based on Node options
- Support any ENV config, ensure nock works with any test proxy config
- Ignore any proxy ENV settings and respond to plain request/response meta
From two perspectives
- App's that use proxies and want to test them.
- Test environments that have proxies but don't want to test them (or want test them all the time).
There's probably some interplay with how much fetch can be configured after the --use-env-proxy argument as to what nock could need to support.
Related issues: https://github.com/nock/nock/issues/2089 https://github.com/nock/nock/issues/2114
As @arunprakashadithyan showed a proxy can currently be worked around by a nock on the proxy server and ignoring the real http host in the path:
nock('http://149.129.239.170:8002', {allowUnmocked: true}).persist()
.get(resource => resource.includes('/comments'))Alternatives
No response
If the feature request is accepted, would you be willing to submit a PR?
- yes
Source: nock/nock