[Solved] How to get `cookieFallback` when making requests using Web SDK?
- 0
- Self Hosted
- Accounts
- Web
Can you share a picture?
So I can get a better understanding
I saw that the subsequent requests had a cookie
header. I didn't check if it had a x-fallback-cookies header
Just 4mins
This is the flow of Appwrite cookies logic.
If the fetch
added native browser cookies that can mean the maybe your browser do accept cookies.
This is part of Appwrite client call
function
let options: RequestInit = {
method,
headers,
credentials: 'include'
};
if (typeof window !== 'undefined' && window.localStorage) {
headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? '';
}
/* More code */
const response = await fetch(url.toString(), options);
You can see the setting of credentials: 'include'
which tell the browser to pass any cookies and the adding of fallback one.
so in this screenshot you can see -> create account POST, OPTIONS request -> create session with email POST, OPTIONS requst -> get accout GET request
now
here you were right about x-fallback-cookies being present in the request headers
but also the cookie header is set too!
So it looks like your browser do save the cookies.
in cookieStorage there is no cookies
this is localStorage
Ohh gotcha
You won't see the cookies because the not saved for the localhost
domain, but for the Appwrite one.
So in order for you to be able to see them, you'll need to go to some Appwrite url like so
https://cloud.appwrite.io/v1/account?project=6469040898e19fe9052c
Replace this ID with your project ID.
Then you'll have access to how the browser stores all the cookies for the current user.
Ohh
Yes
Cross checked just now
Thx!!
<:appwriteupvote:899677724615016528>
about the 1st question:- Does websdk have some way to return the fallback cookie on a successful response
I have a use case for this thing
(The use case is described in the post description)
I think that verification do pass in localhost (and in your react native) so it seems like no.
Oh okay then
[Solved] How to get cookieFallback
when making requests using Web SDK?
Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...