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,