The http-proxy-middleware Nodejs module provides a way of re-target request using a function in the option.router parameter. As described here:
router: function(req) {
return 'http://localhost:8004';
}
I'll need to implement a process that check some aspect in the request (headers, URLs... all that information is at hand in the req
object that function receives) and return a 404 error in some case. Something like this:
router: function(req) {
if (checkRequest(req)) {
return 'http://localhost:8004';
}
else {
// Don't proxy and return a 404 to the client
}
}
However, I don't know how to solve that // Don't proxy and return a 404 to the client
. Looking to http-proxy-middleware is not so evident (or at least I haven't found the way...).
Any help/feedback on this is welcomed!