Dynamic failureRedirect with passport.js
问题 This is my login function atm: app.post("/login", passport.authenticate("local", { failureRedirect: "/login?error=1" }), function (req, res) { res.redirect(req.body.url || "/"); }); I need to put the req.body.url inside the failureRedirect url, so it should looks like: app.post("/login", passport.authenticate("local", { failureRedirect: "/login?error=1&url=" + (req.body.url || "/") }), function (req, res) { res.redirect(req.body.url || "/"); }); It can't work because the req variable is