Okay, from what I'm seeing it uses client side SDK but passes cookies to server side to avoid conflict so a part is executed client sided as I was supposing
The thing is, I don't mind using only Rest API, but the docs are kind of minimal and I have no clue how to properly implement the auth using just rest api. I understand fetching and everything, but what data do I store? do i store it as localstorage like the client sdk? and what does the key/value need to be? What if I want to create a JWT?
It says just this
POST /v1/account/jwt HTTP/1.1
Host: HOSTNAME
Content-Type: application/json
X-Appwrite-Response-Format: 1.4.0
X-Appwrite-Project: 5df5acd0d48c2
But how does the rest api know who the user is? I feel like there's chunks missing
Have you read through this? https://appwrite.io/docs/apis/rest#authentication
That actually helps a lot, thanks Steven! One more question about JWT actually, why is there a legacy sometimes popping up in the cookies using the client sdk?
a_session_projectid_legacy for example
It's not consistent, it's very random on logging-in, as I think the client sdk uses localstorage instead of cookies, so it makes even less sense
The only difference is the samesite option. The legacy one doesn't specify anything for that for backwards compatiblity or something
Ah, alright
TL;DR, You should use Rest API if you use edge runtime
Hey @Steven, Do I need both cookies? Or is just the a_session_projectid enough?
The thing I don't understand, is if you got for example a cookie called a_session_projectid with the value eyJpZCI6IjY1NTI1ZW...TE3MjBiMTdjOSJ9, and I try to fetch /v1/account with that value using rest api fetched via client, it just says 401
As far as I understood it, you only need to create a JWT if you want the server to fetch for example, right?
nvm, seems I got it working!
Thanks everyone for helping with this topic! Setting it as solved.
[Solved] Window not defined | Edge runtime not supported
Yes that one should be enough
Hey how were you able to resolve the problem?
Hey. Are you using nextjs?
Yes
use rest api instead of client sdk
Can you give me kind of pseudo overview on how to use this
With the rest apiece
See reference on docs
I simply send jwt tokens along the request and authenticate that?
You set the token as a cookie with secure and httponly, you use the "Cookie" header as authentication
Thanks
Recommended threads
- How to Display File in Web?
I'm trying to use Appwrite's Storage to store images and display them in my app, however when I use the `getFileView`, `getFileDownload` or `getFilePreview` met...
- Project Paused Despite Daily Active Usag...
I noticed that my project was automatically **paused**, even though it is actively being used. The project is an **attendance application** that is used daily b...
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...