diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 4436c1351..97f71a9ff 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -26,9 +26,15 @@ httpProxy.Server = ProxyServer; */ function createRightProxy(type) { + var webPasses = Object.keys(web).map(function(pass) { + return web[pass]; + }); + var wsPasses = Object.keys(ws).map(function(pass) { + return ws[pass]; + }); return function(options) { return function(req, res /*, [head], [opts] */) { - var passes = (type === 'ws') ? this.wsPasses : this.webPasses, + var passes = (type === 'ws') ? (this.wsPasses || wsPasses) : (this.webPasses || webPasses), args = [].slice.call(arguments), cntr = args.length - 1, head, cbl; @@ -62,7 +68,8 @@ function createRightProxy(type) { if (typeof options[e] === 'string') options[e] = parse_url(options[e]); }); - + + if(typeof this.emit == 'undefined' && !cbl) { throw new Error("You need to pass a callback to handle errors") } for(var i=0; i < passes.length; i++) { /**