From a70dc7b913708c67e7d11c8c99cd6497bd80191e Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 15 Mar 2025 22:50:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20undici=20=E9=85=8D=E7=BD=AE=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/vendor/open-api.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/backend/package.json b/backend/package.json index f1093aa..8487beb 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.18.4", + "version": "2.18.5", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/vendor/open-api.js b/backend/src/vendor/open-api.js index e9cd8fa..3c32b81 100644 --- a/backend/src/vendor/open-api.js +++ b/backend/src/vendor/open-api.js @@ -360,7 +360,12 @@ export function HTTP(defaultOptions = { baseURL: '' }) { } if (isNode) { const undici = eval("require('undici')"); - const { ProxyAgent, EnvHttpProxyAgent, request } = undici; + const { + ProxyAgent, + EnvHttpProxyAgent, + request, + interceptors, + } = undici; const agentOpts = { connect: { rejectUnauthorized: @@ -387,12 +392,18 @@ export function HTTP(defaultOptions = { baseURL: '' }) { const response = await request(opts.url, { ...opts, method: method.toUpperCase(), - dispatcher: opts.proxy + dispatcher: (opts.proxy ? new ProxyAgent({ ...agentOpts, uri: opts.proxy, }) - : new EnvHttpProxyAgent(agentOpts), + : new EnvHttpProxyAgent(agentOpts) + ).compose( + interceptors.redirect({ + maxRedirections: 3, + throwOnMaxRedirects: true, + }), + ), }); resolve({ statusCode: response.statusCode,