I'm sure this question has been answered before, but I couldn't find a good solution. I am new to Appwrite, and I'm selfhosting it at console.domain.com. I've set up a user account that I am trying to create an email session with. I get logged in, but the cookies don't set and as soon as I refresh, it acts like I am logged out even though the session is still active in the appwrite console. I have set the domain in the Web platform in the console to * hoping that would fix the issue but unfortunately it does not.
What is the best way to develop an application locally with auth while hosting the appwrite console on a different domain? I can see the session getting created in the dev console, so that part all works. Do I need to set something in my hosts file?
I believe your apps domain and the domain for appwrite have to be the same for it to set cookies
you can have multiple domains for appwrite
So I'd have to run appwrite locally for it to work?
The fact that the cookies are not saved is browser behavior :/
What cookies get saved where is not something we/you/sdk control with code
The browser decides that is allowed and what isn't
Is there a workaround or a browser setting/different browser I can try? Or should I just go the route of deploying my changes to something like vercel?
Try running Appwrite locally
I think it'll play nice(er)
I will give that a shot, should be fairly easy. Thank You
My memory is fuzzy because I haven't touched my self-hosted setup on a long while. What browser are you using btw?
I believe we fall back to local storage for localhost
For me, it still works on localhost :/
but I know it could be problematic
Firefox, chrome, edge, they all give similar results. I will give the hosting locally a shot, it makes the most sense for now
The fallback cookie is there in localstorage but it doesn't seem to recognize my active session. Then again, Im fairly new to this and Im just cramming all the knowledge into my brain
Fallback is not your cookie, the cookie should be under cookies.
The cookies will not show up in your browser until you actually use them.
This is because the domain the cookies are on, is not the same domain as localhost, but don't worry!
Try making a account.get() request, it should world fine and your cookies will show up.
Running Appwrite locally made this work, I can now log in, refresh the page, and it still has me as logged in
Yeah sounds like browser behavior π
Glad you have a solution π This will also work with some config for your self-hosted instance, but I believe it has to do with configuring domain + SSL correctly? I honestly don't remember.
@Steven What was the issue with cookies not saving for localhost again?
Recommended threads
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...