Next.js Discord

Discord Forum

how can I check if an user has permission to access a page?

Answered
ADNerf posted this in #help-forum
Open in Discord
The question says it all. I'm using PocketBase in case it helps
Answered by B33fb0n3
You can use a middleware for it. Configure your matcher, so it only matches the protected pages and check the user permissions in your middleware. If the user is authorized, dont do anything. Else redirect him to /
View full answer

5 Replies

I want the user to be send back to the home page "/" if they do not have permission to access x page
@ADNerf The question says it all. I'm using PocketBase in case it helps
You can use a middleware for it. Configure your matcher, so it only matches the protected pages and check the user permissions in your middleware. If the user is authorized, dont do anything. Else redirect him to /
Answer
@ADNerf solved?
Yes it worked, thank you very much!
happy to help