Back

Auth Middleware (NEXTJS 13.4)

  • 0
  • Users
  • Accounts
  • Web
benemma
5 May, 2023, 22:02

Any idea how we can implement auth middleware in the new stable NextJS 13.4 app routing directory.

TL;DR
Title: Auth Middleware (NEXTJS 13.4) - Developer wants to limit access to specific pages without loading content before checking permissions - As a new NextJS user, they are unsure if using middleware is the right approach - They encountered issues with installing the demo from https://next-js.ssr.almostapps.eu/ - The demo page is running into a certificate issue - They are developing on localhost using the Appwrite cloud endpoint - They want to know if AppWrite plans to add an easy-to-use middleware feature Solution: - The developer will need to handle the certificate issue if they want to access the
Torsten Dittmann
5 May, 2023, 22:03

@Meldiron might be the most knowledgeable person in this topic 👌

Drake
5 May, 2023, 22:04
Meldiron
6 May, 2023, 08:10

Example above should give you great starting point 😇 If you have any further concerns, feel free to ping me

Badeck
21 Jan, 2024, 15:38

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.

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 ? 🙂

ideclon
21 Jan, 2024, 17:17
  1. I’m not entirely clear on what you’re saying here, but I think you’ve cloned the NextJS AlmostSSR and tried to run it locally? If so, and you want to access it via https, that’s something you’ll have to handle
  2. You’ll have to create a new Project (either on a self hosted Appwrite instance, or in Cloud) and point the application at this new Project.
ideclon
21 Jan, 2024, 17:18

Appwrite 1.5 should come with better support for SSR (IIRC), but I don’t think a routing auth middleware is at all planned.

ideclon
21 Jan, 2024, 17:19

I do like the idea, though, if it can be more genericized

Badeck
21 Jan, 2024, 17:59
  1. The certificate used in the online demo version "https://next-js.ssr.almostapps.eu/" has expired on Jan 13th. 2024
Badeck
21 Jan, 2024, 18:00
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