Ensure proxy configuration follows proper precedence hierarchy and handles different proxy types correctly. User-specified proxy settings should always take priority over environment variables, similar to how browsers handle proxy configuration.
Ensure proxy configuration follows proper precedence hierarchy and handles different proxy types correctly. User-specified proxy settings should always take priority over environment variables, similar to how browsers handle proxy configuration.
When implementing proxy support:
getProxyAgent(host: string, port: number) {
const proxyFromEnv = getProxyForUrl(`https://${host}:${port}`);
if (proxyFromEnv)
return createProxyAgent({ server: proxyFromEnv });
return createProxyAgent(this._proxy); // User config takes precedence
}
sslProxy
for HTTPS connections, not httpsProxy
:
switch (url.protocol) {
case 'http:':
proxy.httpProxy = url.host;
break;
case 'https:':
proxy.sslProxy = url.host; // Not httpsProxy
break;
}
// TODO: switch to URL instance instead of legacy object once https-proxy-agent supports it.
return new HttpsProxyAgent(convertURLtoLegacyUrl(proxyOpts));
This approach ensures consistent proxy behavior across different network scenarios and maintains compatibility with existing proxy infrastructure while preparing for future modernization.
Enter the URL of a public GitHub repository