Skip to content

Commit 4bc1ea0

Browse files
committed
fix: use proxy agent for Schwab token exchange
1 parent fb82382 commit 4bc1ea0

4 files changed

Lines changed: 2193 additions & 32 deletions

File tree

lib/proxy.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const DEFAULT_PORTS = {
2-
'http:': 80,
3-
'https:': 443,
4-
};
1+
const { HttpsProxyAgent } = require('https-proxy-agent');
52
const PLAYWRIGHT_PROXY_BYPASS = 'localhost,127.0.0.1';
63

74
function resolveProxyUrl(env = process.env) {
@@ -63,20 +60,12 @@ function buildAxiosProxyConfig(proxyUrl) {
6360
return {};
6461
}
6562

63+
const proxyAgent = new HttpsProxyAgent(parsed.toString());
64+
6665
return {
67-
proxy: {
68-
protocol: parsed.protocol.replace(':', ''),
69-
host: parsed.hostname,
70-
port: parsed.port ? Number(parsed.port) : DEFAULT_PORTS[parsed.protocol],
71-
...(parsed.username
72-
? {
73-
auth: {
74-
username: decodeURIComponent(parsed.username),
75-
password: decodeURIComponent(parsed.password),
76-
},
77-
}
78-
: {}),
79-
},
66+
proxy: false,
67+
httpAgent: proxyAgent,
68+
httpsAgent: proxyAgent,
8069
};
8170
}
8271

0 commit comments

Comments
 (0)