Suprised PikachuOriginal post
Web Developer
Hello, I am trying to implement a middleware to protect the routes in my website. However it is not working as it is throwing a AppwriteException: User (role: guests) missing scope (account)
at Generator.next ().
Summary
Middleware code is incorrectly checking for authentication. User isn't logged in but it throws an exception. Correct code to properly authenticate users.
Solution:
Update the middleware function to properly check for user authentication before returning NextResponse.next().