diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 789757880..0646194de 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -75,7 +75,7 @@ common.setupSocket = function(socket) { }; common.getPort = function(req) { - var res = req.headers.host.match(/:(\d+)/); + var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : ""; return res ? res[1] : req.connection.pair ? '443' : '80' ;