
I have a react application that checks user authentication on render with account.get() and redirects to login page if error code is 401
It has a sign in button to execute await account.createOAuth2Session('google', 'http://localhost:5173', 'http://localhost:5173/failed');
After logging out cookies are still set but account.get() returns 401 which makes sense After completing oauth process from google appwrite redirects to the homepage which makes a request to account.get() but this request does not have any cookies set and returns 401 so the user is constantly redirected to login page.
Waiting for a second and reloading the page resolves the issue. How do I handle this in a better way?

^ request to account.get()

You could have the new tab send a message to the original tab: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
We do something like this in flutter web: https://github.com/appwrite/playground-for-flutter/blob/ad30fb232a223e118c9429ac1df75f856b6a1d9d/web/auth.html#L6
Recommended threads
- SSR Image Previews
I am using the SSR guide (with SvelteKit) to use Appwrite on both the server and the client. I do this by also passing the cookie back to the client and creatin...
- Multiple Set-Cookie headers collapsed on...
I’m deploying a Next.js 15 app to Appwrite → Deploy → Sites. In app/api/auth/login/route.ts I try to set 3 cookies. Variant A (manual headers): const headers ...
- can't send emails
i explored the docs and it says Messaging.CreateEmail() but this function does not exist , i installed appwrite on next js env everything works fine except thi...
