I'm using Express 4, and I'm using a middleware http-proxy-middleware
( https://github.com/chimurai/http-proxy-middleware), and having the following issues
In normal way, I can do the following to manupulate the response before return to the client
app.get('/v1/users/:username', function(request, response, next) {
var username = request.params.username;
findUserByUsername(username, function(error, user) {
if (error) return next(error);
return response.render('user', user);
});
});
But how do I execute custom logic if I'm using proxy, let's say I want to manipulate some of the data before response to the client? Is there a good pattern to do that with this middleware ?
app.use('/api', proxy({target: 'http://www.example.org', changeOrigin: true}));
Here is the backlink for the issue I put in github as well - https://github.com/chimurai/http-proxy-middleware/issues/97
Any help would be appreciated.