Redirect after login to the referrer (Webpack dev server, in my case)

I believe this should be the default settings (for Node.js), but it isn’t; redirecting to req.headers.referer, after logging in.

There is res.redirect(returnTo || '/user') inside /callback, but it isn’t working.

The solution is simple,

authRouter.get('/login', (req, res, next) => {
  if (req.session) {
    req.session.returnTo = req.headers.referer;
  }

  next();
}, passport.authenticate('auth0', {
  scope: 'openid email profile'
}), function (req, res) {
  res.redirect('/');
});

Planning to create local web server (or perhaps Electron) app.

Hi @patarapolw!

Can you provide some more information on what kind of errors are coming from your code when you attempt this redirection? I’d also recommend looking over this doc of our troubleshooting best practices, especially utilizing console.logs to ensure you’re getting the data you expect.

Let me know what you find out.

Best,
Colin