Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix proxy-agent #867

Merged
merged 10 commits into from
Nov 8, 2023
17 changes: 9 additions & 8 deletions src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,19 @@ function updateRequestAgent(
Required<Pick<UserConfigurationOptions, 'proxy'>>
) {
if (params.proxy.url) {
let proxyUrl = params.proxy.url;
if (params.proxy.username && params.proxy.password) {
proxyUrl = proxyUrl.replace('://', `://${params.proxy.username}:${params.proxy.password}@`);
}

const ProxyAgent = require('proxy-agent').ProxyAgent;
params.request.agentClass = ProxyAgent;
params.request.agentOptions = Object.assign(
{},
params.request.agentOptions = Object.assign({},
params.request.agentOptions,
url.parse(params.proxy.url)
{
getProxyForUrl: (url: string) => proxyUrl
}
);
if (params.proxy.username && params.proxy.password) {
Object.assign(params.request.agentOptions, {
auth: `${params.proxy.username}:${params.proxy.password}`,
});
}
}
}

Expand Down
Loading