-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: support HTTP[S]_PROXY environment variables #57165
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
I believe this will be a notable change. |
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
@@ -26,6 +26,10 @@ module.exports.createFastMessageEvent = createFastMessageEvent | |||
|
|||
module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventSource | |||
|
|||
const api = require('./lib/api') | |||
const Dispatcher = require('./lib/dispatcher/dispatcher') | |||
Object.assign(Dispatcher.prototype, api) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a separate PR in undici nodejs/undici#4064 , let's discuss it there.
This is currently a POC. Just trying to open a PR first to see what folks think about this approach - that is, to support
HTTP_PROXY
etc. environment variables out of the box. The exposure of the lower-level dispatcher and EnvHttpProxyAgent would be a different feature, but I think for many users, having the environment variables supported out of the box is already enough or more important to solve their headaches, while the lower-level utilities are less essential - many other language runtimes/command line tools only support these environment variables out of the box, without necessarily providing more utilities for further customization, and that seems enough for most people who are behind a proxy already.The idea is that we can first make this handling opt-in via another environment variable (
NODE_USE_ENV_PROXY
here, or we can use others if there are better names). And in the future we can enable this flag by default, as this is still opt-in under well-known environment variablesHTTP_PROXY
. I think some investigation is needed to make sure that enabling it by default would not step on the toes of other libraries/tools already recognizing these environment variables and do their own thing.This requires a patch in undici to make the EnvHttpProxyAgent usable from the Node.js bundle, which I included locally in this PR and a locally built bundle for demonstration purpose. I opened a separate PR to undici to see what's the best way to patch it nodejs/undici#4064
I've only tested it with fetch so far, and left a TODO for handling of http global agents.
Refs: nodejs/undici#1650