Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

remove router path query by role nextjs

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There are 2 ways,

  1. Use getServerSideProps which 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.
  2. 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.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading