Initial situation: I have two server-side cookies (httponly) named accessToken and refreshToken. The payload looks like this:
{
"user":{
"firstname":"John",
"lastname":"Doe",
"roles":[
"accounting",
"supporter"
]
}
}
Goal: Handle server-side authorization with Next.js 13 (app folder-based). Some routes should be protected and only accessible to some users with specific roles.
Example:
- GET /login should be accessible to everyone
- GET /dashboard for authorized users only
- GET /accounting only for users with the accounting role
- GET /admin only for users with the role admin