Can we restart the work on overridable globalAgent? #23281
Description
Is your feature request related to a problem? Please describe.
There has been quite a few discussions here (#15620, #8381, #1490) on whether nodejs core should support environment variable for http proxy, and so far the consensus has been that proxy support in core is a slippery slope. Which I agree.
But we do need a fix for this headache: when a userland module use a http library, they often don't expose agent
option, thus blocking users from using available userland proxy module like node-proxy-agent.
Describe the solution you'd like
I personally believe making http(s).globalAgent
overridable is the best way forward:
- userland module can provide whatever proxy support they want, be it http/https/socks/pac.
- user can override
http(s).globalAgent
and be confident that ALL http library will respect it. - it has been worked on before (http: make
globalAgent
ofhttp
andhttps
overridable #11249, Modify https.globalAgent doesn't effect #9057), we should follow it through. - after working on node-fetch for 3 years I realize it's simply too much to ask userland module to expose
agent
or support environment variable: it's often too niche a requirement (eg. why should an oauth lib exposeagent
?), and many strongly believe it to be nodejs core problem.
In short: overridable globalAgent has the lowest impact of all solutions, allow for highest flexibility when it comes to different proxy types, and has userland code ready to take advantage of it.
Describe alternatives you've considered
See linked discussions.