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命令行工具讀取代理配置。如果您只需要一個平台,最好直接使用以下方法之一 - 該軟件包的設計旨在用於跨平台工具。