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
- I'm getting error Invalid `url` param: I...
``` 2025-10-26T12:52:02.292Z [error] AppwriteException: Invalid `url` param: Invalid URI. Register your new client (vercel.com) as a new Web platform on your pr...
- 🚨 Access Restricted Despite Active Cred...
Hello Appwrite Support Team, My organization “Dreamo World Entertainment” currently shows an “Access Restricted” warning due to unpaid invoices. However, my bi...
- Deploy tanstack-start on site
- I am trying to deploy my project build with tanstack-start on site. - issue i am facing is appwrite doesnt provide start command option so i can run 'npm run ...