Skip to content

Commit 4d50915

Browse files
committed
change proxytable routing to route one level shallower
1 parent f188f4f commit 4d50915

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/node-http-proxy/proxy-table.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ ProxyTable.prototype.setRoutes = function (router) {
101101

102102
self.routes.push({
103103
route: route,
104-
target: router[path]
104+
target: router[path],
105+
path: path
105106
});
106107
});
107108
}
@@ -138,6 +139,14 @@ ProxyTable.prototype.getProxyLocation = function (req) {
138139
match;
139140

140141
if (match = target.match(route.route)) {
142+
143+
var root = "/" + route.path.split('/')[1];
144+
var beginningSegment = new RegExp("^" + root);
145+
146+
if(req.url.match(beginningSegment)) {
147+
req.url = req.url.replace(beginningSegment, '');
148+
}
149+
141150
var location = route.target.split(':'),
142151
host = location[0],
143152
port = location.length === 1 ? 80 : location[1];

0 commit comments

Comments
 (0)