I am creating a nodejs api that uses passport and google oauth. I want to redirect users original link they came from. However, in my login route, the "console.log" is never reached. How do I record the originalUrl in an api like this?
I've been trying to follow along of this: Redirecting to previous page after authentication in node.js using passport.js but am stuck.
router.get("/login", passport.authenticate("google", {
scope: ["profile","email"]
}),function(req,res){
console.log(req.originalUrl) //never got to here
res.send(req.user)
})
router.get('/redirect',passport.authenticate('google'),function(req, res) {
console.log(req.originalUrl)//gives a long URL string from google's auth
res.redirect("http://localhost:3000/");//I want to redirect to where the user came from rather than just localhost 3000
// res.send(req.user)
}
);```