I'm unable to make a request to my backend using a JWT created when the user logs in in the frontend.
Everytime I try, even if the access to the collection is set to role:all, I get this error from the backend:
{
"statusCode": 500,
"code": "401",
"error": "Internal Server Error",
"message": "<User> (role: member) missing scope (collections.read)"
}
I'm using Appwrite Node SDK for server part and Appwrite web sdk in the frontend.
This is my login script where I generate the JWT token:
import { Appwrite } from "appwrite";
export const login = async (email, password) => {
const api = new Appwrite();
api.setEndpoint(import.meta.env.VITE_APPWRITE_URL);
api.setProject(import.meta.env.VITE_APPWRITE_PROJECT);
await api.account.createSession(email, password);
const user = await api.account.get();
const jwt = await api.account.createJWT();
return {
jwt: jwt.jwt,
user: {
id: user.$id,
email: user.email,
name: user.name
},
}
}
What am I missing?
Note: I am running everything inside Docker containers.