os proxy config
1.0.0
HTTP工具包的一部分:建造,测试和调试HTTP的强大工具
从Node.js访问所有平台的操作系统代理配置。像这样使用:
import { getSystemProxy } from 'os-proxy-config' ;
const proxy = await getSystemProxy ( ) ; getSystemProxy的承诺解决了类似的事情:
{
"proxyUrl" : " https://proxy-server:123/ " ,
"noProxy" : [ " localhost " , " example.com " ]
} The proxyUrl is returned in a format suitable for use with proxy-agent: it might be an HTTP or HTTPS URL (for an HTTP proxy), a socks:// or socks5:// URL for SOCKS proxies, or a pac+http:// URL (or similar) with the address of a PAC file for PAC-configured proxies.
如果没有配置代理,则它将决定undefined 。如果主要出现问题并且无法检测到设置,则承诺将被拒绝。
这在每个平台上的工作略有不同:
scutil命令行工具读取代理配置。如果您只需要一个平台,最好直接使用以下方法之一 - 该软件包的设计旨在用于跨平台工具。