Rank 7: Quantum Computer
Okay got it, and what is github redirect url?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 7: Quantum Computer
Okay got it, and what is github redirect url?
Rank 7: Quantum Computer
I checked your project and no request is being made to api.imda.cl
Maybe you're running the account.get() function in the server side of your next project?
In that case you wont get cookie unless you're going to use a cookie jar or JWT
What I mean is the account login and getting should run from the intranet.imda.cl frontend code, the code that is exposed to the end user.
Moderator
Rank 7: Quantum Computer
In what part of your code are you running appwrite.account.get()?
Moderator
I have disabled to make some debug testing, but even without call to account.get() the cookie should be created
Rank 7: Quantum Computer
It should but only if the function createOAuth2Session is being execute in a the frontend
Where you run this functions?
Rank 7: Quantum Computer
Oh now I see it
Rank 7: Quantum Computer
My bad
Moderator
I run createOAuth2Session when I click the button
const login = () => createOAuth2Session();
<Button className={classes.loginButton} onClick={login}>Iniciar sesión</Button>Rank 7: Quantum Computer
Can you add at the the flow of checking if the account is logged in in the component mounting point?
Maybe something like this?
const account = new Account(client);
try { const user = await account.get(); console.log(user.email); } catch (e) { console.log('User is not logged in'); }Moderator
Done I can see the user email, so the session is created, it just doesn't create the cookie 🤔
Rank 7: Quantum Computer
Good,
In Appwrite you don't need the cookie
The flow for your app can be something like this
Is that make sense?
Moderator
I have been working with the cookie since v0.7.x 🤔 (not in production)
I can see in the code that response includes a cookie: https://github.com/appwrite/appwrite/blob/master/app/controllers/api/account.php#L613
Rank 7: Quantum Computer
I think I got it
If you would go to this url https://api.imda.cl/v1/ you would see the cookies
The cookies are connect to the Appwrite endpoint
Admin
if you were able to get the email, then there is a session/cookie (unless there was the x-local-fallback header in the request) 🧐
what makes you say there is no cookie?
Moderator
in the application tab there is no cookie, although I see it when I try it in localhost 🤔
Moderator
but as @Binyamin mention if I go to https://api.imda.cl/v1/ the cookie is there
Moderator
so the subdomain intranet.imda.cl can't see the cookies from api.imda.cl 🤔
Moderator
I'm looking information why is that happening
Rank 7: Quantum Computer
It doesn't need to as the session management is between the user and the Appwrite engine
Admin
uhhh not exactly....the client app will send the cookie if hte browser has the cookie...that's probably why the account.get() worked
Moderator
you're right If I see the output of the cookies with (nextjs)
console.log(req.cookies);I can see the cookie setted
Moderator
I'll change this as resolved as my question was answered, thank you both @Steven @Binyamin
Moderator
✅ [Solved] Droplet and App in DigitalOcean
Moderator
✅ [SOLVED] Droplet and App in DigitalOcean