You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
http: deal with the lack of http proxy support in node.js core. #15620
Summary:
Node's http module does not support http proxies by default. This is a unfortunate situation as libraries don't use packages for http that support http proxies and as a result quite a few tools in the Node ecosystem lack the support for http proxies (i.e. through environment variables).
It would be helpful if Node.js could support user proxies and if someone could take the time to implement it, I think the following plan could help get us there:
Old versions of Node.js will never gain http proxy support so it would be important to have a recommended way how to add proxy support to user-land libraries to work on the old versions of Node.js. A guide on "how to support proxies" (maybe combined with a package) seems like a minimum requirement to fix this issue which will help no matter how this topic progresses. (Anyone can start with this, no need to wait for approval, help dearly welcome).
Create a PR to the Node.js docs in which it clearly explains that proxies are the responsibility of user-land and reference the recommended implementation/article in 1.(Just reflecting the current state of affairs)
Create a new discussion on to how the package used in 1. could become part of Node.js core in order to reduce the implementation cost for current and new packages.
Discuss the possibility of creating a Node flag that enables the behavior of 3. in case someone is stuck with user-land code that doesn't implement proxies.
I'm not keen on adding HTTP proxy support in core, especially because it could be a slippery slope (e.g. people may ask to also add support for SOCKS, etc.). IMHO this is easily done in userland with a custom http.Agent. If you want it to be more automatic for all HTTP requests, you can just overwrite the http.globalAgent with your custom implementation.
Reacted by Axel D., Julian, Florian Ebeling, Guilherme Henrique, afd-sanofi, Danijel Markov, Christina Sørensen, hak33m16, Jamie Cahill and Jaen
I'm not sure this is the kind of implementation that people had in mind, but after reading through #8381 I wrote a tiny lib env-proxy-agent that just wraps proxy-from-env and proxy-agent.
I wasn't able to come up with a solution that could overwrite http.globalAgent as I think NO_PROXY needs to be matched against each request individually. This is probably due to my own lack of knowledge about http.Agent but if anyone has guidance on the issue that would be great.
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
Reacted by Steven Vachon, Josh Gavant, Filip Troníček, subinamathew, Lachlan Harris, Florian Ebeling, Guilherme Henrique, cwegener, Dave Powers, Julien Roncaglia and 14 more
For those who are still following: I opened a pull request to implement support for http/https built-ins #58980, following the support for fetch in #57165, both would be first opt-in under NODE_USE_ENV_PROXY=1 before we figure out whether they can be enabled by default without breakages.
Activity
[-]http: improve http proxy problematic[/-][+]http: deal with the lack of http proxy support in node.js core.[/+]mscdex commentedon Sep 26, 2017
I'm not keen on adding HTTP proxy support in core, especially because it could be a slippery slope (e.g. people may ask to also add support for SOCKS, etc.). IMHO this is easily done in userland with a custom
http.Agent. If you want it to be more automatic for all HTTP requests, you can just overwrite thehttp.globalAgentwith your custom implementation.martinheidegger commentedon Sep 26, 2017
@mscdex The point of this issue is to bikeshed this particular discussion until point
3.Fishrock123 commentedon Sep 26, 2017
Did you mean "never gain http proxy support"?
martinheidegger commentedon Sep 26, 2017
#15620 (comment) Changed
jackjocross commentedon Jan 9, 2018
I'm not sure this is the kind of implementation that people had in mind, but after reading through #8381 I wrote a tiny lib env-proxy-agent that just wraps proxy-from-env and proxy-agent.
I wasn't able to come up with a solution that could overwrite
http.globalAgentas I thinkNO_PROXYneeds to be matched against each request individually. This is probably due to my own lack of knowledge abouthttp.Agentbut if anyone has guidance on the issue that would be great.stevenvachon commentedon Jan 9, 2018
@crosscompile why write a separate project when you could've instead fulfilled TooTallNate/node-proxy-agent#11
jackjocross commentedon Jan 9, 2018
@stevenvachon thanks for pointing that out, I did not see that open issue on node-proxy-agent.
I pushed up some changes to my fork of node-proxy-agent that I'm hoping to finish up soon, will follow up in TooTallNate/node-proxy-agent#11 as it's more relevant there.
chrmarti commentedon Oct 2, 2018
Overwriting
http.globalAgentas suggest above does not work (#9057). One has to pass theagentoption to each and every request.github-actions commentedon Feb 22, 2022
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
2 remaining items
github-actions commentedon Mar 29, 2022
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.
c33s commentedon Mar 29, 2022
reopen please
aburd commentedon Mar 15, 2024
Pretty please re-open this?
joyeecheung commentedon Jul 8, 2025
For those who are still following: I opened a pull request to implement support for http/https built-ins #58980, following the support for fetch in #57165, both would be first opt-in under NODE_USE_ENV_PROXY=1 before we figure out whether they can be enabled by default without breakages.
test: move http proxy tests to test/client-proxy
http,https: add built-in proxy support in http/https.request and Agent
test: move http proxy tests to test/client-proxy
http,https: add built-in proxy support in http/https.request and Agent
test: move http proxy tests to test/client-proxy
http,https: add built-in proxy support in http/https.request and Agent