diff --git a/doc/api/http.md b/doc/api/http.md index 77dd231ebb6fef..32752562fa2b0f 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -4361,6 +4361,31 @@ added: Set the maximum number of idle HTTP parsers. +## `http.setGlobalProxyFromEnv(proxyEnv)` + + + +* `proxyEnv` {Object} An object containing proxy configuration. This accepts the + same options as the `proxyEnv` option accepted by [`Agent`][] +* Returns: {Function} A 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. + ## Class: `WebSocket`