Skip to content

Commit

Permalink
Fixes #29 - TypeError: HttpsProxyAgent is not a constructor.
Browse files Browse the repository at this point in the history
Now properly using the http[s]-proxy-agent module constructor.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Dec 19, 2023
1 parent 56c48cf commit 0f26c71
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cometd-nodejs-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ module.exports = {
const url = require('url');
const httpc = require('http');
const https = require('https');
const HttpcProxyAgent = require('http-proxy-agent');
const HttpsProxyAgent = require('https-proxy-agent');
const httpcProxyAgent = require('http-proxy-agent');
const httpsProxyAgent = require('https-proxy-agent');
const ws = require('ws');

let window = global['window'];
Expand Down Expand Up @@ -184,8 +184,8 @@ module.exports = {
}
if (isIncluded) {
_debug('proxying', serverURI.href, 'via', proxy);
const agentOpts = Object.assign(new url.URL(proxy), _agentOptions);
return _secure(serverURI) ? new HttpsProxyAgent(agentOpts) : new HttpcProxyAgent(agentOpts);
const agentOpts = Object.assign({}, _agentOptions);
return _secure(serverURI) ? new httpsProxyAgent.HttpsProxyAgent(proxy, agentOpts) : new httpcProxyAgent.HttpProxyAgent(proxy, agentOpts);
}
}
return _secure(serverURI) ? _agents : _agentc;
Expand Down

0 comments on commit 0f26c71

Please sign in to comment.