Skip to content

Commit

Permalink
Fix protocol selection
Browse files Browse the repository at this point in the history
  • Loading branch information
leppert committed Mar 24, 2023
1 parent 08c7762 commit e6b8966
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e6b8966

Please sign in to comment.