Skip to content

Commit 53a2653

Browse files
committed
[fix] closes #553
1 parent 3330e12 commit 53a2653

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/http-proxy/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ httpProxy.Server = ProxyServer;
2626
*/
2727

2828
function createRightProxy(type) {
29+
var webPasses = Object.keys(web).map(function(pass) {
30+
return web[pass];
31+
});
32+
var wsPasses = Object.keys(ws).map(function(pass) {
33+
return ws[pass];
34+
});
2935
return function(options) {
3036
return function(req, res /*, [head], [opts] */) {
31-
var passes = (type === 'ws') ? this.wsPasses : this.webPasses,
37+
var passes = (type === 'ws') ? (this.wsPasses || wsPasses) : (this.webPasses || webPasses),
3238
args = [].slice.call(arguments),
3339
cntr = args.length - 1,
3440
head, cbl;
@@ -62,7 +68,8 @@ function createRightProxy(type) {
6268
if (typeof options[e] === 'string')
6369
options[e] = parse_url(options[e]);
6470
});
65-
71+
72+
if(typeof this.emit == 'undefined' && !cbl) { throw new Error("You need to pass a callback to handle errors") }
6673

6774
for(var i=0; i < passes.length; i++) {
6875
/**

0 commit comments

Comments
 (0)