Skip to content

Commit cdf4605

Browse files
authored
fix(cli): use ProxyAgent instead of HttpsProxyAgent (#1038)
1 parent 8a0e3dc commit cdf4605

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"compression": "^1.7.4",
1919
"debug": "^4.3.1",
2020
"express": "^4.17.1",
21-
"https-proxy-agent": "^5.0.0",
21+
"proxy-agent": "^6.4.0",
2222
"inquirer": "^6.3.1",
2323
"isomorphic-fetch": "^3.0.0",
2424
"lighthouse": "12.1.0",

packages/cli/src/fetch.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
'use strict';
77

88
const fetch = require('isomorphic-fetch');
9-
const {HttpsProxyAgent} = require('https-proxy-agent');
9+
const {ProxyAgent} = require('proxy-agent');
1010

1111
/** @type import('isomorphic-fetch') */
1212
module.exports = (url, options) => {
13-
/** @type {Parameters<import('isomorphic-fetch')>[1] & { agent?: import('https-proxy-agent').HttpsProxyAgent }} */
13+
/** @type {Parameters<import('isomorphic-fetch')>[1] & { agent?: import('proxy-agent').ProxyAgent }} */
1414
const instanceOptions = {
1515
...options,
1616
};
1717

18-
if (!instanceOptions.agent && process.env.HTTP_PROXY) {
19-
instanceOptions.agent = new HttpsProxyAgent(process.env.HTTP_PROXY);
18+
if (
19+
!instanceOptions.agent &&
20+
(process.env.HTTP_PROXY || process.env.HTTPS_PROXY || process.env.NO_PROXY)
21+
) {
22+
instanceOptions.agent = new ProxyAgent();
2023
}
2124

2225
return fetch(url, instanceOptions);

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -15822,7 +15822,7 @@ [email protected]:
1582215822
proxy-from-env "^1.1.0"
1582315823
socks-proxy-agent "^8.0.2"
1582415824

15825-
15825+
[email protected], proxy-agent@^6.4.0:
1582615826
version "6.4.0"
1582715827
resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.4.0.tgz#b4e2dd51dee2b377748aef8d45604c2d7608652d"
1582815828
integrity sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==

0 commit comments

Comments
 (0)