diff --git a/lib/dispatcher/proxy-agent.js b/lib/dispatcher/proxy-agent.js index c5b4d51babb..a6dda163913 100644 --- a/lib/dispatcher/proxy-agent.js +++ b/lib/dispatcher/proxy-agent.js @@ -87,12 +87,7 @@ class ProxyAgent extends DispatcherBase { callback(null, socket) return } - let servername - if (this[kRequestTls]) { - servername = this[kRequestTls].servername - } else { - servername = opts.servername - } + const servername = this[kRequestTls]?.servername || opts.servername this[kConnectEndpoint]({ ...opts, servername, httpSocket: socket }, callback) } catch (err) { if (err.code === 'ERR_TLS_CERT_ALTNAME_INVALID') {