update: 增加对带用户名密码的代理支持

This commit is contained in:
陈晗 2023-08-20 11:12:48 +08:00
parent e1c4ed4268
commit 8c70630d2d

View File

@ -147,10 +147,11 @@ const createRequest = (method, url, data = {}, options) => {
} else {
const purl = new URL(options.proxy)
if (purl.hostname) {
const agent = tunnel.httpsOverHttp({
const agent = tunnel[purl.protocol === 'https' ? 'httpsOverHttp' : 'httpOverHttp']({
proxy: {
host: purl.hostname,
port: purl.port || 80,
proxyAuth: purl.username && purl.password ? (purl.username + ':' + purl.password) : ''
},
})
settings.httpsAgent = agent