fix: 兼容5和7的proxy依赖

This commit is contained in:
ikechan8370 2023-09-12 11:08:14 +08:00
parent 5e7d73908f
commit f620e10abb
8 changed files with 727 additions and 334 deletions

17
utils/proxy.js Normal file
View file

@ -0,0 +1,17 @@
// workaround for ver 7.x and ver 5.x
import HttpsProxyAgent from 'https-proxy-agent'
let proxy = HttpsProxyAgent
if (typeof proxy !== 'function') {
proxy = (p) => {
return new HttpsProxyAgent.HttpsProxyAgent(p)
}
}
/**
* return a proxy function
* @returns {*|createHttpsProxyAgent|((opts: (string | createHttpsProxyAgent.HttpsProxyAgentOptions)) => HttpsProxyAgent)}
*/
export function getProxy () {
return proxy
}