I have implemented a route handler in Express 3.4.8 to check for privileges on all my routes. In case the credentials sent with each request are invalid, I want to respond with a status of 403.
app.all('*',function(req,res,next){
//req.body contains an object `credentials`
res.send(403);
});
However, when I send a response with a status of 403, the req.body object becomes empty. This is strange because the request is coming from a correct Angular app.
If I remove the status code from the response, everything works fine. Here is the modified code:
app.all('*',function(req,res,next){
res.send('Im not a status code');
});
When I use this code, req.body contains the expected credentials. It seems like the issue only occurs when sending a 403 status code.
Has anyone experienced this issue and found a solution?
This problem is causing a lot of frustration for me. It doesn't make sense at all. Even when I log req.body at the beginning of the logic flow, before the authentication check, it still fails.