http.setGlobalProxyFromEnv([proxyEnv])
proxyEnv<Object> 包含代理配置的对象。它接受与Agent所接受的proxyEnv选项相同的选项。默认值:process.env。- 返回:<Function> 一个将原始代理和调度器设置恢复到调用此
http.setGlobalProxyFromEnv()之前状态的函数。
在运行时动态重置全局配置,以启用 fetch() 和 http.request()/https.request() 的内置代理支持,作为使用 --use-env-proxy 标志或 NODE_USE_ENV_PROXY 环境变量的替代方法。它还可以用于覆盖从环境变量配置的设置。
🌐 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.
由于此函数会重置全局配置,任何之前配置的 http.globalAgent、https.globalAgent 或 undici 全局调度器在调用此函数后都会被覆盖。建议在发起任何请求之前调用该函数,并避免在请求过程中调用它。
🌐 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.
有关代理 URL 格式和 NO_PROXY 语法的详细信息,请参见 内置代理支持。
🌐 See Built-in Proxy Support for details on proxy URL formats and NO_PROXY
syntax.