Merge pull request #1787 from movefreechen/master

update: 增加对带用户名密码的代理支持
This commit is contained in:
binaryify 2023-08-20 14:17:14 +08:00 committed by GitHub
commit 7f21fbcda1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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