In this Rocketseat example, we configure nextjs with axios to login to a backend via the JWT token. We handled various errors such as Expired Token, Invalid Token and created the refresh Token function to renew the token if it is expired.
Neste exemplo da Rocketseat, configuramos o nextjs com o axios para fazer login num backend através do token JWT. Tratamos vários erros, como Token expirado, Token inválido e criamos a função de refresh Token, para renovar o token caso esteja expirado.
- NextJS - Framework to ReactJS
- Nookies - Library to control cookies on next
- JWT Decode - Library to decode JWT
- Axios - API Client
- Clone example Backend and install dependencies using
npm i
oryarn
- Run command
npm run dev
on backend folder - Clone this project and install dependencies using
npm i
oryarn
- Run command
npm run dev
on folder of this project