0

I have use case when user which is not logged in-app, try to open some page.

He is redirected on /login page, I need to get that URL which user tries to open.

In the authenticate method I Add next code:

return (req: Express.Request) => {

// then with **req.originalUrl** I will get the URL which users execute

// But my app does not work, it's stuck like loading the initial page all the time, without content
}

Here is entire function:

public static authenticate(isRedirect = false) {
    return (req: Express.Request) => {
      return passport.authenticate('jwt', {
        session: false,
        ...(isRedirect && { failureRedirect: `/login?redirectUrl=${req.originalUrl || ''}` })
      });
    };
  }

How to get that req.originalUrl but to my app steal works as before?

Mark James
  • 338
  • 4
  • 15
  • 43
  • Does this answer your question? [Redirecting to previous page after authentication in node.js using passport.js](https://stackoverflow.com/questions/13335881/redirecting-to-previous-page-after-authentication-in-node-js-using-passport-js) – makeitmorehuman Feb 03 '20 at 11:22
  • No, cus I have a problem to get `req.url`, not to implement redirection on prev URL after login. – Mark James Feb 03 '20 at 12:50

0 Answers0