diff --git a/lib/node-http-proxy/proxy-table.js b/lib/node-http-proxy/proxy-table.js index 749ea7d..376d77c 100644 --- a/lib/node-http-proxy/proxy-table.js +++ b/lib/node-http-proxy/proxy-table.js @@ -101,7 +101,8 @@ ProxyTable.prototype.setRoutes = function (router) { self.routes.push({ route: route, - target: router[path] + target: router[path], + path: path }); }); } @@ -138,6 +139,14 @@ ProxyTable.prototype.getProxyLocation = function (req) { match; if (match = target.match(route.route)) { + + var root = "/" + route.path.split('/')[1]; + var beginningSegment = new RegExp("^" + root); + + if(req.url.match(beginningSegment)) { + req.url = req.url.replace(beginningSegment, ''); + } + var location = route.target.split(':'), host = location[0], port = location.length === 1 ? 80 : location[1];