mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-06-04 11:13:59 +08:00
feat: undici 配置重定向
This commit is contained in:
parent
fc56df7bfd
commit
a70dc7b913
@ -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": {
|
||||
|
17
backend/src/vendor/open-api.js
vendored
17
backend/src/vendor/open-api.js
vendored
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user