in the initial stage of developing my app, i thot to handle the session in server-side only. then as the app have grown, i felt the need of client-side session as well (mainly for realtime connection). so i decided to maintain both client and server side sessions. for server-side i'm setting all the cookies and stuff, and everything there working quite perfectly. for client-side session, i'm just setting the cookieFallback
value from X-Fallback-Cookies
header in the localStorage. it was working perfectly.
but suddenly it stopped working. when i hit the /account
route for getting the currently logged-in user, it says unauthorized now.
idk why it's happening. i'm not so sure which part of my code to even put here to debug this.
I also have tried comparing the X-Fallback-Cookies
value i'm sending with every request from both client and server side. both are same
Stack: NextJS@14 Appwrite: Cloud Login System: Email-Password
lemme know if u need more info
you really should be using cookies in production rather than the fallback cookie header
yeah i know. that's the recommended option. but i'm in local development now. so at least for local development, i need the fallback cookie header
for client-side session, i'm just setting the cookieFallback value from X-Fallback-Cookies header in the localStorage. it was working perfectly.
How are you creating the session and setting the header?
I also have tried comparing the X-Fallback-Cookies value i'm sending with every request from both client and server side. both are same
Would you please share?
this is the headers object i'm passing with every request. one ss is from browser console and another from terminal
how about in the actual network request (network logs from browser dev tools)?
i'm seeing two request to /account
in the network tab. one's status code is 204 and one's is 401
204's request headers:
401's request headers:
Interesting...I think this looks okay. How many sessions does the user have?
one
Wait, there's another cookie. Can you try deleting that cookie?
i think it's from the appwrite console, to manage my login session there
There are 2 cookies. The a_session_console one is for your console user connecting to the appwrite console. The other one is for the end user of your project
yeah that's what I'm saying. so for my project, it has one cookie only, right?. or i'm missing something?
Your browser has two cookies. You need to delete the project one
I've tried it from an incognito window and it worked. there I noticed under the request headers of /account
request, I don't have the Cookies
value which I'm getting in the normal window. It means it's getting conflicted with some other cookies. now speaking of deleting the project's cookie, i'm not so sure how to do it. do i have to do it from the browser? or from the code?
Go to the appwrite console, open the browser dev tools, switch to the application tab and then cookies
i see it has cookies for my project. should i delete these? and i wonder why it has cookies for my project.
Yes, delete the project cookies. They're always set by Appwrite. The browser doesn't always use them so that's why we have the fallback
oh i get it. so when i'll go for a custom domain for appwrite, it'll work with the cookies by default instead of the fallback
Yes, there will be no fallback cookie client side
but isn't the fallback cookie and the main cookie value same? if yes, then it should work with the fallback as well i think?
Sort of yes. Appwrite won't return the fallback cookie header if the custom domain is set. The cookies are http only so they can't be accessed using JavaScript
[SOLVED] cookieFallback
in localStorage suddenly stopped working
Recommended threads
- 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...
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...