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",
|
"name": "sub-store",
|
||||||
"version": "2.18.4",
|
"version": "2.18.5",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"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) {
|
if (isNode) {
|
||||||
const undici = eval("require('undici')");
|
const undici = eval("require('undici')");
|
||||||
const { ProxyAgent, EnvHttpProxyAgent, request } = undici;
|
const {
|
||||||
|
ProxyAgent,
|
||||||
|
EnvHttpProxyAgent,
|
||||||
|
request,
|
||||||
|
interceptors,
|
||||||
|
} = undici;
|
||||||
const agentOpts = {
|
const agentOpts = {
|
||||||
connect: {
|
connect: {
|
||||||
rejectUnauthorized:
|
rejectUnauthorized:
|
||||||
@ -387,12 +392,18 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
|||||||
const response = await request(opts.url, {
|
const response = await request(opts.url, {
|
||||||
...opts,
|
...opts,
|
||||||
method: method.toUpperCase(),
|
method: method.toUpperCase(),
|
||||||
dispatcher: opts.proxy
|
dispatcher: (opts.proxy
|
||||||
? new ProxyAgent({
|
? new ProxyAgent({
|
||||||
...agentOpts,
|
...agentOpts,
|
||||||
uri: opts.proxy,
|
uri: opts.proxy,
|
||||||
})
|
})
|
||||||
: new EnvHttpProxyAgent(agentOpts),
|
: new EnvHttpProxyAgent(agentOpts)
|
||||||
|
).compose(
|
||||||
|
interceptors.redirect({
|
||||||
|
maxRedirections: 3,
|
||||||
|
throwOnMaxRedirects: true,
|
||||||
|
}),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
resolve({
|
resolve({
|
||||||
statusCode: response.statusCode,
|
statusCode: response.statusCode,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user