M
http.setGlobalProxyFromEnv
History
Added in: v25.4.0, v24.14.0
v25.4.0, v24.14.0
Introduced in: v0.10.0
v0.10.0
http.setGlobalProxyFromEnv(proxyEnv?): Function
Attributes
proxyEnv?:
ObjectAn object containing proxy configuration. This accepts the
same options as the
proxyEnv option accepted by Agent. Default:
process.env.Returns:
FunctionA function that restores the original agent and dispatcher
settings to the state before this
http.setGlobalProxyFromEnv() is invoked.Dynamically resets the global configurations to enable built-in proxy support for
fetch() and http.request()/https.request() at runtime, as an alternative
to using the --use-env-proxy flag or NODE_USE_ENV_PROXY environment variable.
It can also be used to override settings configured from the environment variables.
As this function resets the global configurations, any previously configured
http.globalAgent, https.globalAgent or undici global dispatcher would be
overridden after this function is invoked. It's recommended to invoke it before any
requests are made and avoid invoking it in the middle of any requests.
See Built-in Proxy Support for details on proxy URL formats and NO_PROXY
syntax.