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 {