Skip to content

Commit b83f355

Browse files
committed
Move proxy fix to cubejs-backend-shared instead and use that
1 parent bda24b2 commit b83f355

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

packages/cubejs-api-gateway/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"moment-timezone": "^0.5.27",
4646
"nexus": "^1.1.0",
4747
"node-fetch": "^2.6.1",
48-
"proxy-agent": "^6.4.0",
4948
"ramda": "^0.27.0",
5049
"uuid": "^8.3.2"
5150
},

packages/cubejs-api-gateway/src/jwk.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/* eslint-disable no-restricted-syntax */
22
import crypto from 'crypto';
3-
import { asyncMemoizeBackground, asyncRetry, BackgroundMemoizeOptions } from '@cubejs-backend/shared';
3+
import { asyncMemoizeBackground, asyncRetry, BackgroundMemoizeOptions, getHttpAgentForProxySettings } from '@cubejs-backend/shared';
44
import fetch from 'node-fetch';
55
import jwkToPem from 'jwk-to-pem';
6-
import { ProxyAgent } from 'proxy-agent';
76
import { JWTOptions } from './interfaces';
87

98
const HEADER_REGEXP = /([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?/g;
@@ -52,7 +51,7 @@ export type JWKsFetcherOptions = Pick<BackgroundMemoizeOptions<any, any>, 'onBac
5251

5352
export const createJWKsFetcher = (jwtOptions: JWTOptions, options: JWKsFetcherOptions) => {
5453
const fetchJwkUrl = asyncMemoizeBackground(async (url: string) => {
55-
const response = await asyncRetry(() => fetch(url, { agent: new ProxyAgent() }), {
54+
const response = await asyncRetry(() => fetch(url, { agent: await getHttpAgentForProxySettings() }), {
5655
times: jwtOptions.jwkRetry || 3,
5756
});
5857
const json = await response.json();

packages/cubejs-backend-shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"decompress": "^4.2.1",
4343
"env-var": "^6.3.0",
4444
"fs-extra": "^9.1.0",
45-
"http-proxy-agent": "^4.0.1",
45+
"proxy-agent": "^6.4.0",
4646
"moment-range": "^4.0.1",
4747
"moment-timezone": "^0.5.33",
4848
"node-fetch": "^2.6.1",

packages/cubejs-backend-shared/src/proxy.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { exec } from 'child_process';
2-
import HttpsProxyAgent from 'http-proxy-agent';
2+
import { ProxyAgent } from 'proxy-agent';
33

44
function getCommandOutput(command: string) {
55
return new Promise<string>((resolve, reject) => {
@@ -14,6 +14,7 @@ function getCommandOutput(command: string) {
1414
});
1515
}
1616

17+
// deprecated, use ProxyAgent instead
1718
export async function getProxySettings() {
1819
const [proxy] = (
1920
await Promise.all([getCommandOutput('npm config -g get https-proxy'), getCommandOutput('npm config -g get proxy')])
@@ -25,7 +26,5 @@ export async function getProxySettings() {
2526
}
2627

2728
export async function getHttpAgentForProxySettings() {
28-
const proxy = await getProxySettings();
29-
30-
return proxy ? HttpsProxyAgent(proxy) : undefined;
29+
return new ProxyAgent();
3130
}

0 commit comments

Comments
 (0)