Skip to content

Commit

Permalink
fix: Fix proxy-agent (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
congminh1254 authored Nov 8, 2023
1 parent 2d7cc67 commit 3de7586
Showing 1 changed file with 9 additions and 8 deletions.
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

0 comments on commit 3de7586

Please sign in to comment.