From 381a37fbaa6b61c887eda743897ae00afb825bdf Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 15 Nov 2024 23:52:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=90=86=E8=AE=BE=E7=BD=AE=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=B8=BA=E5=8F=AF=E5=85=A8=E5=B1=80=E7=94=9F=E6=95=88?= =?UTF-8?q?=EF=BC=8C=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E4=B8=AD=E7=9A=84?= =?UTF-8?q?https=5Fproxy=E8=AE=BE=E7=BD=AE=E5=B0=86=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/basic/src/utils/util.request.ts | 15 +++++++++++++-- .../certd-client/src/views/sys/settings/index.vue | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core/basic/src/utils/util.request.ts b/packages/core/basic/src/utils/util.request.ts index d4c7144b..73867523 100644 --- a/packages/core/basic/src/utils/util.request.ts +++ b/packages/core/basic/src/utils/util.request.ts @@ -202,6 +202,9 @@ export type HttpClient = { request(config: HttpRequestConfig): Promise>; }; +// const http_proxy_backup = process.env.HTTP_PROXY || process.env.http_proxy; +// const https_proxy_backup = process.env.HTTPS_PROXY || process.env.https_proxy; + export type CreateAgentOptions = { httpProxy?: string; httpsProxy?: string; @@ -216,20 +219,28 @@ export function createAgent(opts: CreateAgentOptions = {}) { ); let httpAgent, httpsAgent; - const httpProxy = opts.httpProxy || process.env.HTTP_PROXY || process.env.http_proxy; + const httpProxy = opts.httpProxy; if (httpProxy) { + process.env.HTTP_PROXY = httpProxy; + process.env.http_proxy = httpProxy; logger.info('use httpProxy:', httpProxy); httpAgent = new HttpProxyAgent(httpProxy, opts as any); merge(httpAgent.options, opts); } else { + process.env.HTTP_PROXY = ''; + process.env.http_proxy = ''; httpAgent = new nodeHttp.Agent(opts); } - const httpsProxy = opts.httpsProxy || process.env.HTTPS_PROXY || process.env.https_proxy; + const httpsProxy = opts.httpsProxy; if (httpsProxy) { + process.env.HTTPS_PROXY = httpProxy; + process.env.https_proxy = httpProxy; logger.info('use httpsProxy:', httpsProxy); httpsAgent = new HttpsProxyAgent(httpsProxy, opts as any); merge(httpsAgent.options, opts); } else { + process.env.HTTPS_PROXY = ''; + process.env.https_proxy = ''; httpsAgent = new https.Agent(opts); } return { diff --git a/packages/ui/certd-client/src/views/sys/settings/index.vue b/packages/ui/certd-client/src/views/sys/settings/index.vue index cff25ef7..a2a52dc1 100644 --- a/packages/ui/certd-client/src/views/sys/settings/index.vue +++ b/packages/ui/certd-client/src/views/sys/settings/index.vue @@ -38,7 +38,7 @@ 测试 -
一般这两个代理填一样的
+
一般这两个代理填一样的,保存后再测试