fix: proxy auth

This commit is contained in:
DIYgod
2024-03-31 02:28:26 +08:00
parent 59631b2e9b
commit d83c951d8c
2 changed files with 6 additions and 5 deletions
+6 -2
View File
@@ -30,10 +30,14 @@ if (proxyIsPAC) {
agent = new PacProxyAgent(`pac+${proxyUri}`);
} else if (proxyUri) {
if (proxyUri.startsWith('http')) {
agent = new HttpsProxyAgent(proxyUri);
agent = new HttpsProxyAgent(proxyUri, {
headers: {
'proxy-authorization': config.proxy?.auth ? `Basic ${config.proxy?.auth}` : undefined,
},
});
dispatcher = new ProxyAgent({
uri: proxyUri,
token: proxyObj?.auth ? `Basic ${proxyObj.auth}` : undefined,
token: config.proxy?.auth ? `Basic ${config.proxy?.auth}` : undefined,
requestTls: {
rejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0',
},
-3
View File
@@ -54,9 +54,6 @@ const getWrappedGet: <T extends Get>(origin: T) => T = (origin) =>
if (proxyRegex.test(url.toString()) && url.protocol.startsWith('http') && url.host !== proxy.proxyUrlHandler?.host) {
options.agent = proxy.agent;
if (proxy.proxyObj.auth) {
options.headers['Proxy-Authorization'] = `Basic ${proxy.proxyObj.auth}`;
}
}
}