{"id":3117,"date":"2014-03-16T20:29:16","date_gmt":"2014-03-16T20:29:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/node-js-http-proxy-crashes-collection-of-common-programming-errors\/"},"modified":"2014-03-16T20:29:16","modified_gmt":"2014-03-16T20:29:16","slug":"node-js-http-proxy-crashes-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/16\/node-js-http-proxy-crashes-collection-of-common-programming-errors\/","title":{"rendered":"node.js http-proxy crashes-Collection of common programming errors"},"content":{"rendered":"<p>I have the following http-proxy code<\/p>\n<pre><code>var httpProxy = require('http-proxy');\nvar server = require(\".\/server\");\nvar router = require(\".\/route\")\n\nvar proxyServer = httpProxy.createServer ({\n    pathnameOnly: true,\n    router: {\n        '\/page':       '127.0.0.1:8080',\n        '\/api':       '127.0.0.1:8081'\n    }\n});\nproxyServer.listen(8888);\n<\/code><\/pre>\n<p>As soon as it receives a request, I get the following exception.<\/p>\n<p>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 &#8216;regexp&#8217; 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)<\/p>\n<p>What am I doing wrong?<\/p>\n<p>Thank you.<\/p>\n<p>-Nick<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have the following http-proxy code var httpProxy = require(&#8216;http-proxy&#8217;); var server = require(&#8220;.\/server&#8221;); var router = require(&#8220;.\/route&#8221;) var proxyServer = httpProxy.createServer ({ pathnameOnly: true, router: { &#8216;\/page&#8217;: &#8216;127.0.0.1:8080&#8217;, &#8216;\/api&#8217;: &#8216;127.0.0.1:8081&#8217; } }); 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3117","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3117"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3117\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}