Rael
15 Aug, 2024, 11:00

Hey I am trying to follow the react tutorial and im on the first section of creating a login page everything worked fine but when logging out im being met with the cors error. I have added a platform with localhost as the name and I even tried * wildcard but the logout will not work due to cors can anyone assist please

TL;DR
Issue: CORS-related problems with deleting sessions in Appwrite. Solution: Mark the post as solved and specify the solution is adding the localhost as a platform in the project settings. Another potential workaround provided by a developer is to add the localhost as 'Access-Control-Allow-Origin' when calling the 'deleteSession' function.
Rael
15 Aug, 2024, 11:08

this is what I am using

await account.deleteSession('current'); setLoggedInUser(null);

Rael
15 Aug, 2024, 11:19

Just would love to get this sorted as I'm trying to develop ui to advertise my skills

ideclon
19 Aug, 2024, 09:48

I’m pretty sure we’ve seen this before, but I don’t remember (and I can’t find rn) if or how it was resolved

Rael
19 Aug, 2024, 09:52

thats not a problem I appreciate the help its just strange how Ive followed the steps on your tutorial and the youtube channel to avoid cors and only the deletesessions() is not working for me

Rael
19 Aug, 2024, 11:59

i get the user sessions but when it comes to deleting the session for loging out purpose it fails

ideclon
19 Aug, 2024, 12:01

Yeah, I’ve seen that happen specifically with deleting sessions in the past

Rael
19 Aug, 2024, 12:03

I have tried to do variations of the delete session but unfortunately nothing I have tried testing the rest via postman but get a user role error

ideclon
19 Aug, 2024, 12:04

You won’t be able to hit the deleteSession() endpoint in Postman without having an active session there.

Rael
19 Aug, 2024, 12:07

okay I ses so this is redundant unless I can get the active session

Steven
19 Aug, 2024, 14:38

One odd thing is I don't see the project in the headers 🧐

Steven
19 Aug, 2024, 14:38

What was the result of the other request that failed?

Rael
19 Aug, 2024, 15:34

It is very strange is there a step I'm missing cause I'm following the documents step by step

Rael
19 Aug, 2024, 15:35

Where am I suppose to put the project in the headers I can share my code

ideclon
19 Aug, 2024, 15:58

I think that might just be because that’s the preflight, not the actual request

Steven
19 Aug, 2024, 22:51

I would still expect it to have the project header

Steven
19 Aug, 2024, 22:51

You're supposed to call setProject()

Rael
20 Aug, 2024, 04:58

I do have the setProject in the config file but I found another document where I will give that a try

ideclon
20 Aug, 2024, 05:43

@\geekdev You can see the Project header is present here

Rael
20 Aug, 2024, 10:43

I've tried this doc to try a new approach but still issues when it comes to the logout

https://appwrite.io/docs/tutorials/react/step-5

Rael
20 Aug, 2024, 11:36

access-control-allow-methods: * which I am using as a wildcard for the platform aswell as local host so would I need to manually write that in the code to by pass this

Rael
20 Aug, 2024, 11:37
Rael
20 Aug, 2024, 11:53

issue appears to have been resolved I believe it was due to my extension

ideclon
20 Aug, 2024, 11:59

Oh yes! Now I remember - the last time this came up it was a browser extension too!

ideclon
20 Aug, 2024, 12:00

If your issue has been solved, you can mark this post as closed by adding "[SOLVED]" to the beginning of the title

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more