diff --git a/packages/cubejs-api-gateway/package.json b/packages/cubejs-api-gateway/package.json index ab4e6eb91ee1d..c440807239d9f 100644 --- a/packages/cubejs-api-gateway/package.json +++ b/packages/cubejs-api-gateway/package.json @@ -46,6 +46,7 @@ "moment-timezone": "^0.5.27", "nexus": "^1.1.0", "node-fetch": "^2.6.1", + "proxy-agent": "^6.4.0", "ramda": "^0.27.0", "uuid": "^8.3.2" }, diff --git a/packages/cubejs-api-gateway/src/jwk.ts b/packages/cubejs-api-gateway/src/jwk.ts index 06ae30ed6150a..9518b0b42a74a 100644 --- a/packages/cubejs-api-gateway/src/jwk.ts +++ b/packages/cubejs-api-gateway/src/jwk.ts @@ -3,6 +3,7 @@ import crypto from 'crypto'; import { asyncMemoizeBackground, asyncRetry, BackgroundMemoizeOptions } from '@cubejs-backend/shared'; import fetch from 'node-fetch'; import jwkToPem from 'jwk-to-pem'; +import { ProxyAgent } from 'proxy-agent'; import { JWTOptions } from './interfaces'; const HEADER_REGEXP = /([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?/g; @@ -51,7 +52,7 @@ export type JWKsFetcherOptions = Pick, 'onBac export const createJWKsFetcher = (jwtOptions: JWTOptions, options: JWKsFetcherOptions) => { const fetchJwkUrl = asyncMemoizeBackground(async (url: string) => { - const response = await asyncRetry(() => fetch(url), { + const response = await asyncRetry(() => fetch(url, { agent: new ProxyAgent() }), { times: jwtOptions.jwkRetry || 3, }); const json = await response.json();