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
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...