
user logins -> i create session token on server side -> i create cookies
Then i'm using the following code to create an appwrite session based on the session token & protect my frontend routes.
But now I want to protect my api routes, what is the best approach? Since the token can be changed on the client side, how do I verify the integrity of it ?
export async function createAppwriteSessionClient() { const client = new Client() .setEndpoint(process.env.APPWRITE_ENDPOINT) .setProject(process.env.APPWRITE_PROJECT)
const session = cookies().get("session"); if (!session || !session.value) { throw new Error("No session"); }
client.setSession(session.value);
return { get account() { return new Account(client); }, }; }

Should I call createAppwriteSessionClient() everytime before making any requests to appwrite? assuming client.setSession(session.value)
will reject tampered session tokens?
Recommended threads
- Unable to create push providers - FCM or...
Currently unable to create a push provider for FCM or APNS.... https://github.com/appwrite/console/issues/2045 When uploading a file... FCM = Valid file retu...
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
- Help with 409 Error on Relationship Setu...
I ran into a 409 document_already_exists issue. with AppWrite so I tried to debug. Here's what I've set up: Collection A has 3 attributes and a two-way 1-to-m...
