This is a follow-up on #8381.
_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:
1. _(Just reflecting the current state of affairs)_1. could become part of Node.js core in order to reduce the implementation cost for current and new packages.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.
@mscdex The point of this issue is to bikeshed this particular discussion until point 3.
Old versions of Node.js will never gain http support so it would be (...)
Did you mean "never gain http _proxy_ support"?
https://github.com/nodejs/node/issues/15620#issuecomment-332231929 Changed
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.
@crosscompile why write a separate project when you could've instead fulfilled https://github.com/TooTallNate/node-proxy-agent/issues/11
@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.
Overwriting http.globalAgent as suggest above does not work (https://github.com/nodejs/node/issues/9057). One has to pass the agent option to each and every request.
Most helpful comment
@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.