From 01b40278f5bbba9b53c2159db8758630d40e3a3a Mon Sep 17 00:00:00 2001 From: Mithlesh Singh Date: Mon, 24 Jun 2024 14:05:11 +0530 Subject: [PATCH 1/3] fix(axios) as we use httpProxyAgent disabling default axios proxy with kicks in with https_proxy env set --- packages/utils/lib/axios.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/utils/lib/axios.ts b/packages/utils/lib/axios.ts index f18e2b1161..07cc929af1 100644 --- a/packages/utils/lib/axios.ts +++ b/packages/utils/lib/axios.ts @@ -6,8 +6,8 @@ import type { Agent as HttpAgent } from 'node:http'; import type { Agent as HttpsAgent } from 'node:https'; import https from 'node:https'; -export let httpAgent: HttpProxyAgent | HttpAgent = new http.Agent(); -export let httpsAgent: HttpsProxyAgent | HttpsAgent = new https.Agent(); +export let httpAgent: HttpProxyAgent | HttpAgent = new http.Agent(); +export let httpsAgent: HttpsProxyAgent | HttpsAgent = new https.Agent(); const hasHttpProxy = process.env['http_proxy'] || process.env['HTTP_PROXY']; const hasHttpsProxy = process.env['https_proxy'] || process.env['HTTPS_PROXY']; @@ -20,6 +20,7 @@ if (hasHttpsProxy) { } export const axiosInstance = axios.create({ + proxy: false, httpAgent: httpAgent, httpsAgent: httpsAgent }); From 80275c5d2fac9c1b1479002b4c57ecffe2064029 Mon Sep 17 00:00:00 2001 From: Mithlesh Singh Date: Mon, 24 Jun 2024 14:38:08 +0530 Subject: [PATCH 2/3] fix(axios) fixing es lint --- packages/utils/lib/axios.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/lib/axios.ts b/packages/utils/lib/axios.ts index 07cc929af1..deea4e5c18 100644 --- a/packages/utils/lib/axios.ts +++ b/packages/utils/lib/axios.ts @@ -6,8 +6,8 @@ import type { Agent as HttpAgent } from 'node:http'; import type { Agent as HttpsAgent } from 'node:https'; import https from 'node:https'; -export let httpAgent: HttpProxyAgent | HttpAgent = new http.Agent(); -export let httpsAgent: HttpsProxyAgent | HttpsAgent = new https.Agent(); +export let httpAgent: HttpProxyAgent | HttpAgent = new http.Agent(); +export let httpsAgent: HttpsProxyAgent | HttpsAgent = new https.Agent(); const hasHttpProxy = process.env['http_proxy'] || process.env['HTTP_PROXY']; const hasHttpsProxy = process.env['https_proxy'] || process.env['HTTPS_PROXY']; From 12c3f1515a93a2db1d91dc24494b05d8a1d2d868 Mon Sep 17 00:00:00 2001 From: Mithlesh Singh Date: Wed, 26 Jun 2024 10:50:06 +0530 Subject: [PATCH 3/3] makinf proxy: false conditional --- packages/utils/lib/axios.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/utils/lib/axios.ts b/packages/utils/lib/axios.ts index deea4e5c18..4561591550 100644 --- a/packages/utils/lib/axios.ts +++ b/packages/utils/lib/axios.ts @@ -1,5 +1,6 @@ import { HttpProxyAgent } from 'http-proxy-agent'; import { HttpsProxyAgent } from 'https-proxy-agent'; +import type { AxiosRequestConfig } from 'axios'; import axios from 'axios'; import http from 'node:http'; import type { Agent as HttpAgent } from 'node:http'; @@ -19,8 +20,13 @@ if (hasHttpsProxy) { httpsAgent = new HttpsProxyAgent(hasHttpsProxy); } -export const axiosInstance = axios.create({ - proxy: false, +const config: AxiosRequestConfig = { httpAgent: httpAgent, httpsAgent: httpsAgent -}); +}; + +if (hasHttpProxy || hasHttpsProxy) { + config.proxy = false; +} + +export const axiosInstance = axios.create(config);