First I am not sure how to send the JWT to the nitro api, secondly I am not sure how to actually create the client, is it good practice to create it in a middleware? wouldn't that slow everything down?
export default defineEventHandler((event) => {
event.context.appwrite = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT(jwt); // Your secret JSON Web
event.context.account = new sdk.Account(event.context.appwrite);
})
Best practice would be to have some provider that will hold all of your Appwrite services.
As for nitro, the only way to get JWT is with Appwrite client side js SDK. https://appwrite.io/docs/client/account?sdk=web-default#accountCreateJWT
Check this to see how to get JWT in server side - https://discord.com/channels/564160730845151244/1123704308966379552/1123972307057119273
Otherwise you'll need to send the JWT from the client side to backend one each request.
Recommended threads
- SSR Image Previews
I am using the SSR guide (with SvelteKit) to use Appwrite on both the server and the client. I do this by also passing the cookie back to the client and creatin...
- Multiple Set-Cookie headers collapsed on...
I’m deploying a Next.js 15 app to Appwrite → Deploy → Sites. In app/api/auth/login/route.ts I try to set 3 cookies. Variant A (manual headers): const headers ...
- can't send emails
i explored the docs and it says Messaging.CreateEmail() but this function does not exist , i installed appwrite on next js env everything works fine except thi...