Open pwasem opened 9 years ago
Hi there,
I workaround this problem with playing with proxyRequest.path value like so
proxy.on('proxyReq', function (proxyRequest, request, response, options) {
if (proxyRequest.path == '/service/api') {
proxyRequest.path = '/some/other/path/to/api';
}
});
I've a similar scenario that you and I've just made this package to deal with that kind of requirements.
Hope it could be useful in some or other way: https://github.com/h2non/rocky
Hi,
I' am trying to build a reverse proxy with expressjs and node-http-proxy. UI and API Services should be dynamically mounted with expressjs and requests should be forwarded via node-http-proxy.
e.g. UI: source.com/service/ui ---> sometarget.com/some/path/ui API: source.com/service/api ---> othertarget.com/some/other/path/to/api
forward.js (middleware using node-http-proxy)
app.js (using expressjs)
My problem One time api and ui request are forward correctly, but if I have an ui that has some link (a href='/internal/link/of/that/ui') following that link results in a Cannot GET '/internal/link/of/that/ui' because the '/service/ui/' is not prepended.
How can this be fixed? Do I need to "regexp the response.body" myself? if yes, how to do this? or is there some option I can provide to proxy.web()?
Thank you very much in advance!