From b61e1062bfc9ea0738a9c9beb9a68d86a0091ee0 Mon Sep 17 00:00:00 2001 From: shaw Date: Fri, 5 Dec 2025 08:37:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcreate=5Fproxyagent?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/geminiHandlers.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/handlers/geminiHandlers.js b/src/handlers/geminiHandlers.js index cfdf35e0..87295d31 100644 --- a/src/handlers/geminiHandlers.js +++ b/src/handlers/geminiHandlers.js @@ -449,9 +449,8 @@ async function handleMessages(req, res) { // 添加代理配置 if (proxyConfig) { - const proxyHelper = new ProxyHelper() - axiosConfig.httpsAgent = proxyHelper.createProxyAgent(proxyConfig) - axiosConfig.httpAgent = proxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpsAgent = ProxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpAgent = ProxyHelper.createProxyAgent(proxyConfig) } try { @@ -732,9 +731,8 @@ async function handleModels(req, res) { headers: { 'Content-Type': 'application/json' } } if (proxyConfig) { - const proxyHelper = new ProxyHelper() - axiosConfig.httpsAgent = proxyHelper.createProxyAgent(proxyConfig) - axiosConfig.httpAgent = proxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpsAgent = ProxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpAgent = ProxyHelper.createProxyAgent(proxyConfig) } const response = await axios(axiosConfig) models = (response.data.models || []).map((m) => ({ @@ -1234,9 +1232,8 @@ async function handleCountTokens(req, res) { } if (proxyConfig) { - const proxyHelper = new ProxyHelper() - axiosConfig.httpsAgent = proxyHelper.createProxyAgent(proxyConfig) - axiosConfig.httpAgent = proxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpsAgent = ProxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpAgent = ProxyHelper.createProxyAgent(proxyConfig) } try { @@ -1963,9 +1960,8 @@ async function handleStandardGenerateContent(req, res) { } if (proxyConfig) { - const proxyHelper = new ProxyHelper() - axiosConfig.httpsAgent = proxyHelper.createProxyAgent(proxyConfig) - axiosConfig.httpAgent = proxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpsAgent = ProxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpAgent = ProxyHelper.createProxyAgent(proxyConfig) } try { @@ -2246,9 +2242,8 @@ async function handleStandardStreamGenerateContent(req, res) { } if (proxyConfig) { - const proxyHelper = new ProxyHelper() - axiosConfig.httpsAgent = proxyHelper.createProxyAgent(proxyConfig) - axiosConfig.httpAgent = proxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpsAgent = ProxyHelper.createProxyAgent(proxyConfig) + axiosConfig.httpAgent = ProxyHelper.createProxyAgent(proxyConfig) } try {