Redirect from Rails monolith to NextJS with JWT authentication

Viewed 164

We have a large full stack rails monolith application that we want to slowly migrate to be a Rails backend and a NextJS frontend(s).

Our current strategy is:

  • rebuild certain pages in NextJS
  • click on link in old monolith
  • be redirected to NextJS app
  • interact with rails API from NextJS (client and server side) without the user logging in again

Ideal requirements:

  • Use JWT gem / Json Web Tokens for authentication
  • Not be restricted to running on same domain / subdomain

What is the most secure way to handle the redirect, while passing the token and enabling access to that token in both the client and server side of NextJS?

0 Answers
Related