Skip to content

Commit 7654f60

Browse files
committed
Replicate http_proxy/https_proxy logic into htmlOnlyFetcher
1 parent cb8dd27 commit 7654f60

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/archivist/fetcher/htmlOnlyFetcher.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,31 @@ export default async function fetch(url, config) {
1414
headers: { 'Accept-Language': config.language },
1515
};
1616

17-
if (url.startsWith('https:') && process.env.HTTPS_PROXY) {
18-
nodeFetchOptions.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
19-
} else if (url.startsWith('http:') && process.env.HTTP_PROXY) {
20-
nodeFetchOptions.agent = new HttpProxyAgent(process.env.HTTP_PROXY);
17+
// Handle http_proxy/https_proxy environment variables precedence
18+
let http_proxy = null;
19+
let https_proxy = null;
20+
21+
if (process.env.http_proxy) {
22+
http_proxy = process.env.http_proxy;
23+
}
24+
else if (process.env.HTTP_PROXY) {
25+
http_proxy = process.env.HTTP_PROXY;
26+
}
27+
28+
if (process.env.https_proxy) {
29+
https_proxy = process.env.https_proxy;
30+
}
31+
else if (process.env.HTTPS_PROXY) {
32+
https_proxy = process.env.HTTPS_PROXY;
33+
}
34+
else if (http_proxy) {
35+
https_proxy = http_proxy;
36+
}
37+
38+
if (url.startsWith('https:') && https_proxy) {
39+
nodeFetchOptions.agent = new HttpsProxyAgent(https_proxy);
40+
} else if (url.startsWith('http:') && http_proxy) {
41+
nodeFetchOptions.agent = new HttpProxyAgent(http_proxy);
2142
}
2243

2344
let response;

0 commit comments

Comments
 (0)