lundi 6 avril 2015

Chaining Express.js 4's res.status(403) to a redirect

I'd like to send a response code of 403 if the requesting user is not authenticated, but I'd also like to redirect when the request was an HTML request. I've been finding that Express 4 doesn't allow this:



res.status(403).redirect('/login')


Does anyone know of a way to handle this? This might not be a limitation of Express, since I'm asking to essentially pass two headers, but I don't see why that should be the case. I should be able to pass a "not authenticated" response and redirect the user all in one go.


Aucun commentaire:

Enregistrer un commentaire