🐛 Fix: fix proxy setting bug

ISSUES CLOSED: #1
This commit is contained in:
萌萌哒赫萝 2023-02-17 08:41:45 +08:00
parent baa741226b
commit 22bee0b9a6

View File

@ -221,24 +221,30 @@ export const trimPath = (path: string) => path.replace(/^\/+|\/+$/g, '').replace
export const getAgent = (proxy:any, https: boolean = true) => {
const formatProxy = formatHttpProxy(proxy, 'string') as any
const opt = {
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxFreeSockets: 256,
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
proxy: formatProxy.replace('127.0.0.1', 'localhost')
}
if (https) {
return formatProxy
? {
https: new HttpsProxyAgent(opt)
https: new HttpsProxyAgent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxFreeSockets: 256,
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
proxy: formatProxy.replace('127.0.0.1', 'localhost')
})
}
: {}
} else {
return formatProxy
? {
http: new HttpProxyAgent(opt)
http: new HttpProxyAgent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 256,
maxFreeSockets: 256,
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
proxy: formatProxy.replace('127.0.0.1', 'localhost')
})
}
: {}
}