[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
- functions domain error
I cannot set up the domain for function Iβm trying to add the domain api.example.com I can only use Cloudflare as the DNS provider because my domain provider do...
- Storage Bucket Permissions
Hey folks, when enabling CRUD on the bucket level for the role any, should the bucket be accessible when using a session client?
- Python function - error while creating /...
I have been trying to figure it out myself for the last 2 days. I have self-hosted appwrite instance, and I am running python 3.12 function. It works great up t...