Hey,I'm making an app and I have to have a persistent session variable after redirects. I'm using cookie-session.Here is how the routes go:/login -> redirects to API to login with external service and it redirects me back to the /callback. That's where I try to grab my session data so I can redirect my users back to my page.Login Route:app.get("/login", async (req, res) => { let origin = req.headers.referer; const redirect_to = req.query.redirect_to; console.log("Spotify auth begins"); var scopes = "user-read-email user-top-read"; req.session.redirect_to = redirect_to; req.session.frontend_URL = origin; console.log("session redirect_to", req.session.redirect_to); console.log("session frontend_URL", req.session.frontend_URL); /*** Redirect happens here ***/ } In here I can see req.session assignments are done perfectly.After when it redirects me to /callbackCallback route:console.log("Frontend URL is:", req.session.frontend_URL); console.log("Redirect path is:", req.session.redirect_to); These guys are returning undefined.Here's the configuration for session object:app.use( session({ name: "session", keys: ["key1", "key2"], maxAge: 10 * 60 * 1000, }) ); Any help appreciated!
Submitted September 25, 2020 at 01:54PM by mrnovembeer
No comments:
Post a Comment