From e6b89665d82a0e9ba37174710fb2e05576bd9592 Mon Sep 17 00:00:00 2001 From: Greg Leppert Date: Tue, 14 Mar 2023 13:04:33 -0400 Subject: [PATCH] Fix protocol selection --- utils/proxy.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/proxy.js b/utils/proxy.js index 6bb41b84..9228687e 100644 --- a/utils/proxy.js +++ b/utils/proxy.js @@ -71,13 +71,17 @@ export function createProxy (options) { const url = new URL(urlString) + const protocol = url.protocol === UNKNOWN_PROTOCOL && request.socket instanceof TLSSocket + ? 'https:' + : 'http:' + const options = { - port: parseInt(url.port) || (url.protocol === 'https:' ? 443 : 80), + port: parseInt(url.port) || (protocol === 'https:' ? 443 : 80), host: url.hostname, servername: url.hostname } - const httpModule = url.protocol === 'https:' || request.socket instanceof TLSSocket ? https : http + const httpModule = protocol === 'https:' ? https : http httpModule .request(options)