No, I'm using a client sdk. As an individual user.
Okay, I think I can spot the issue
When you're running the account.createEmailSession action the returned cookie are not being sent back in the results.
I used this same api in an application using react, and when I created the user session, via email, it automatically saved the cookie in the browser, in a way that I still don't understand well (I'm a beginner).
I'm using insomnia to simulate this login, similarly to what I did in react, however I believe that the return data should be the cookie. Only it is not returned.
You can see here at
\appwrite\src\client.ts That you never getting back the Cookies you just get the json
And the only you will have those cookies is if you do it in window mode
Otherwise you can use the REST option with JWT
In browser it will work
But in your code you can see that the client is node
let me watch it calmly one moment
My suggestion for a quick way around it is it just to add request to get a JWT and send it back with the results, and from then you can connect using the JWT
const result = await account.createEmailSession(email, password);
const jwt = await account.createJWT();
return response.status(201).json({
message: "...",
data : {result, jwt}
});
I'm trying to understand what you're trying to say. What do you mean I would only get the cookie back in window mode? In case, I know that in the browser, somehow the cookie is saved and it works. But for me to test on my backend I would need to have a JWT, is that it? Is there a problem with insomnia requests? I had not tested with postman.
Sorry for the delay, I have difficulties with the English language.
It's bit complex issue But every time you do a request and cookies are returned they are saved inside a Cookie Jar When you running this action inside the browser or any other API tester it will take care of the Jar
But, in your situation is not insomnia issue but the node-fetch one where the account functions running on
So when insomnia contacting your endpoint aka create_email_session it have all the cookies, but when your NodeJS app is contacting your AppWrite engine it does that using node-fetch and is not saving the Cookies inside the Jar
Can you show me your node package.json?
Hum, ok. I´ĺl try.
a little complex for me still.
for sure.
Every instance can store the cookies inside the jar and provide them when there is a new request but not the node fetch in your case
And I don't think you can have a way around it without JWT
I understand. I'll test with JWT, I hadn't thought of that context. In case, if someone consumes my custom api, in the browser, it wouldn't need to access via JWT, would it? The JWT would just be for me to test as an authenticated user, right?
No
The JWT and all the app data is inside your express code and is not exposed unless you send it somehow
ok, my friend.
👍
Thank you for your support!
You could try to manually make the API call using fetch or a axios and checking the response headers for the cookie
Recommended threads
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...