Skip to content

Commit 291bbac

Browse files
committed
fix: use http-proxy-agent
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 33d79db commit 291bbac

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

package-lock.json

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"fast-toml": "^0.5.4",
5050
"fast-xml-parser": "^4.2.4",
5151
"help": "^3.0.2",
52+
"https-proxy-agent": "^7.0.6",
5253
"node-fetch": "^2.6.7",
5354
"packageurl-js": "^1.0.2",
5455
"yargs": "^17.7.2"

src/analysis.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {EOL} from "os";
44
import {RegexNotToBeLogged, getCustom} from "./tools.js";
55
import http from 'node:http';
66
import https from 'node:https';
7+
import { HttpsProxyAgent } from "https-proxy-agent";
78

89
export default { requestComponent, requestStack, validateToken }
910

@@ -18,14 +19,11 @@ const rhdaOperationTypeHeader = "rhda-operation-type"
1819
* @returns {Object} The fetch options with proxy agent if applicable
1920
*/
2021
function addProxyAgent(options, opts) {
21-
const proxyUrl = getCustom('EXHORT_PROXY_URL', null, opts);
22-
if (proxyUrl) {
23-
const proxyUrlObj = new URL(proxyUrl);
24-
options.agent = proxyUrlObj.protocol === 'https:'
25-
? new https.Agent({ proxy: proxyUrl })
26-
: new http.Agent({ proxy: proxyUrl });
27-
}
28-
return options;
22+
const proxyUrl = getCustom('EXHORT_PROXY_URL', null, opts);
23+
if (proxyUrl) {
24+
options.agent = new HttpsProxyAgent(proxyUrl);
25+
}
26+
return options;
2927
}
3028

3129
/**

0 commit comments

Comments
 (0)