villadora / express-http-proxy

Proxy middleware for express/connect
Other
1.23k stars 235 forks source link

Trouble with "proxyReqPathResolver" #447

Closed skasidej closed 4 years ago

skasidej commented 4 years ago

Right now I'm trying to resolve everything from localhost:2000 to localhost:3000/blog. But only the first entry page localhost:3000/blog is being resolved automatically, not like the other pages.

For example localhost:2000 should be resolved as localhost:3000/blog which works fine localhost:2000/welcome should be resolved as localhost:3000/blog/welcome, but it's not

Here is my code, even without Promise it gives the same result.

app.use('/blog', proxy('localhost:2000, {
    proxyReqPathResolver: function(req) {
        return new Promise(function (resolve, reject) {
            setTimeout(function () {
                resolve(req.url);
            }, 200);
        });
    }
}))