Back

Middleware Authentication / Permission Check (NextJS)

  • 0
  • Users
  • Accounts
  • Web
Badeck
21 Jan, 2024, 15:51

Hi @Meldiron ,

I would like to limit access to specific pages, without loading the content of the pages before checking user's permissions. As I am new to NextJS I am wondering if middleware is the way to do it. But what I read let me think it is.

So to begin with I tried to install the demo of https://next-js.ssr.almostapps.eu/, as you suggested in another thread.

But I ran into several issues.

1# - It looks like your demo page is running into a certificate issue (I let you check your browser console when you login and fetch client session).

2# - I dev on localhost, using appwrite cloud endpoint. It looks like the only 2 options here is to modify my hostname file OR selfhost appwrite.

Do you guys at AppWrite have any plan to add a "middleware" easy to use feature soon ? 🙂

TL;DR
Hi <@287294735054274560>, You can limit access to specific pages in NextJS by using middleware for authentication and permission checks. It is the recommended approach for this task. Regarding the issues you faced with the demo at https://next-js.ssr.almostapps.eu/: 1# There seems to be a certificate issue on the demo page. Please check your browser console for more details when you login and fetch the client session. 2# If you are developing on localhost and using the AppWrite cloud endpoint, there are two options available: modifying your hostname file or self-hosting AppWrite. As for the "
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more