I have a nextjs project. I am using middleware to develop role based access to routes. I am using below code in middleware.ts file for geting session
const session = await account.getSession('current');
Issues:
[AppwriteException: User (role: guests) missing scope (account)] {
name: 'AppwriteException',
code: 401,
type: 'general_unauthorized_scope',
response: {
message: 'User (role: guests) missing scope (account)',
code: 401,
type: 'general_unauthorized_scope',
version: '1.6.0'
}
TL;DR
Developers are encountering an AppwriteException related to a missing scope (account) for a user with the role of guests. This error is occurring in a nextjs project while using middleware for role-based access to routes. To fix this issue, the developers need to ensure that the user role (guests) has the necessary scope (account) set up in the middleware configuration.