node.js http-proxy crashes-Collection of common programming errors
I have the following http-proxy code
var httpProxy = require('http-proxy');
var server = require("./server");
var router = require("./route")
var proxyServer = httpProxy.createServer ({
pathnameOnly: true,
router: {
'/page': '127.0.0.1:8080',
'/api': '127.0.0.1:8081'
}
});
proxyServer.listen(8888);
As soon as it receives a request, I get the following exception.
C:\dev\hephaestus\hephaestus\nodeserver\node_modules\http-proxy\lib\node-http-proxy\proxy-table.js:225 if (target.match(route.source.regexp)) { ^ TypeError: Cannot read property ‘regexp’ of undefined at ProxyTable.getProxyLocation (C:\dev\hephaestus\hephaestus\nodeserver\node_modules\http-proxy\lib\node-http-proxy\proxy-table.js:225:36) at RoutingProxy.proxyRequest (C:\dev\hephaestus\hephaestus\nodeserver\node_modules\http-proxy\lib\node-http-proxy\routing-proxy.js:193:32) at Array.0 (C:\dev\hephaestus\hephaestus\nodeserver\node_modules\http-proxy\lib\node-http-proxy.js:160:15) at Server.handler (C:\dev\hephaestus\hephaestus\nodeserver\node_modules\http-proxy\lib\node-http-proxy.js:175:40) at Server.EventEmitter.emit (events.js:98:17) at HTTPParser.parser.onIncoming (http.js:2056:12) at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:120:23) at Socket.socket.ondata (http.js:1946:22) at TCP.onread (net.js:525:27)
What am I doing wrong?
Thank you.
-Nick