From 0f26c7196df772583731529b9b687c72ae97f9f5 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 19 Dec 2023 16:20:07 +0100 Subject: [PATCH] Fixes #29 - TypeError: HttpsProxyAgent is not a constructor. Now properly using the http[s]-proxy-agent module constructor. Signed-off-by: Simone Bordet --- cometd-nodejs-client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cometd-nodejs-client.js b/cometd-nodejs-client.js index bffffa7..1a08df0 100644 --- a/cometd-nodejs-client.js +++ b/cometd-nodejs-client.js @@ -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']; @@ -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;