i have issue with next/router. I have 2 account admin and user, account admin can see and accesses to path:’/inventory’ and i don’t allow account user accesses path:’/inventory’ when login. Can you guys help me? Thank you so much.
>Solution :
There are 2 ways,
- Use
getServerSidePropswhich is triggered each time when you access the page, in this function decide the type of user, if user is admin then allow, otherwise redirect to any other page or error page. - Create a API which give you the user type, then call that api from the front end and decide whether you need to show the page or not.