Server Side redirection with NextJS

How to redirect a user if the authentication token expires with nextjs.

This is simple, in my case in my project I created a utils folder and the files SSRGuest SSRGuestAuth.

File SSRGuest

code-snapshot-ssrguest

File SSRGuestAuth

code-snapshot-ssrguestauth

SSRGuestAuth's function causes it to be redirected to the login page if auth token is expired. which is in our index file of our dashboard.

code-snapshot-SSRGuestAuth-function

Company

PostsCareersContato

Install App

©2022 Aleksander Palamar. All rights reserved | CNPJ 26.328.604/0001-55