Skip to content

Commit a801353

Browse files
1 parent 900511c commit a801353

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/sdk/server-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"license": "Apache-2.0",
4747
"dependencies": {
4848
"@launchdarkly/js-server-sdk-common": "2.16.0",
49-
"https-proxy-agent": "^5.0.1",
49+
"https-proxy-agent": "^7.0.6",
5050
"launchdarkly-eventsource": "2.2.0"
5151
},
5252
"devDependencies": {

packages/sdk/server-node/src/platform/NodeRequests.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as http from 'http';
22
import * as https from 'https';
3-
import * as createHttpsProxyAgent from 'https-proxy-agent';
4-
import { HttpsProxyAgentOptions } from 'https-proxy-agent';
3+
import { HttpsProxyAgent, HttpsProxyAgentOptions } from 'https-proxy-agent';
54
// No types for the event source.
65
// @ts-ignore
76
import { EventSource as LDEventSource } from 'launchdarkly-eventsource';
7+
import { format as formatUrl } from 'url';
88
import { promisify } from 'util';
99
import * as zlib from 'zlib';
1010

@@ -52,11 +52,13 @@ function processProxyOptions(
5252
proxyOptions: LDProxyOptions,
5353
additional: https.AgentOptions = {},
5454
): https.Agent | http.Agent {
55-
const protocol = proxyOptions.scheme?.startsWith('https') ? 'https:' : 'http';
56-
const parsedOptions: HttpsProxyAgentOptions & { [index: string]: any } = {
55+
const proxyUrl = formatUrl({
56+
protocol: proxyOptions.scheme?.startsWith('https') ? 'https:' : 'http:',
57+
slashes: true,
58+
hostname: proxyOptions.host,
5759
port: proxyOptions.port,
58-
host: proxyOptions.host,
59-
protocol,
60+
});
61+
const parsedOptions: HttpsProxyAgentOptions<string> = {
6062
...additional,
6163
};
6264
if (proxyOptions.auth) {
@@ -67,12 +69,12 @@ function processProxyOptions(
6769

6870
// Node does not take kindly to undefined keys.
6971
Object.keys(parsedOptions).forEach((key) => {
70-
if (parsedOptions[key] === undefined) {
71-
delete parsedOptions[key];
72+
if (parsedOptions[key as keyof HttpsProxyAgentOptions<string>] === undefined) {
73+
delete parsedOptions[key as keyof HttpsProxyAgentOptions<string>];
7274
}
7375
});
7476

75-
return createHttpsProxyAgent(parsedOptions);
77+
return new HttpsProxyAgent(proxyUrl, parsedOptions);
7678
}
7779

7880
function createAgent(

0 commit comments

Comments
 (0)