
Hi! i am new to react and i am making a movie web app as a first project (learning while doing so i barely know stuff now) I've been struggling with CORS errors for hours and tried everything. Here's what's happening:
Timeline of Issues:
- Initial Problem (Anonymous Sessions): Access to fetch at 'https://cloud.appwrite.io/v1/account/sessions/anonymous' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
i tried everything: Added Web platform with hostname: localhost as i cant include port number (localhost:5173) Tried also the * in host name but nothing worked All platforms show as enabled (green toggle) all the ids are correct and matching Still getting CORS errors
so i switched to email/password authentication: but same thing Access to fetch at 'https://cloud.appwrite.io/v1/account' from origin 'http://localhost:5173' has been blocked by CORS policy
been trying for hours so if anyone can help it will be so appreciated, thanks for listening.

Heyy 👋 Localhost is allowed by default, even without web platform. Most commonly, the issue is wrong project ID. Can you check that was set correctly?

i already did and its correct

Can you please open network tab in your browser, locate the request, and copy it as CURL? Seeing that CURL command will help us greatly in identifying the issue

sorry bro i didnt understand i dont know much can you explain how to do that?

what do you mean by network tab

No worries at all man, here is quick example how I took it from one of my Appwrite apps:

If you get both requests (one for OPTIONS, one for POST), both is useful. But sicne it's CORS, I would guess only one such request will be there

there is one for local host, and multiple ones called account that failed because now the code is after i changed it to email/pass verification which do i send

We are interested in one where CORS fail, based on your message above, that should be /v1/account/sessions/anonymous

Thanks for sharing, you can delete the message now

Unexpected thing happened here, curl command included your console session. I recommend you to sign out, and sign back in to Appwrite Console, to be extra safe https://cloud.appwrite.io/

ok

did

Thanks 🙏
Hmm, this request seems totally fine 🤔
Also looking at it, it's different path, /v1/account
. it might be that some request work, but some dont (regarding CORS).
That might be because you do new Client()
in multiple places in your code - and in some places you set project ID properly, and in some the ID is missing.
Let's please check your code if that might be the case. If that's not it, we will need to find request that is causing the CORS error - we will need URL in cors error to match URL in the curl request you copy

do i copy paste or send a zip file ?

if copy paste which ones you need

If you are fine with that, you can zip whole thing for me, and I can take a quick look. If you have any kind of secrets, like api keys in the code, you can send it to me over Discord PMs as well

ok i will send as dm because also i wrote the email/pass

For refference, problem was in endpoint, cloud.appwrite.io
was used, but project was in New York, so we had to switch to nyc.cloud.appwrite.io
in setEndpoint
, resolving the issue.
Simsili is facing issues still, but likely just rate limit, which can be resolved by waiting 1 hour, or using dev keys https://appwrite.io/blog/post/announcing-dev-keys
Recommended threads
- Appwrite Sites - getaddrinfo ENOTFOUND
Has anyone had a problem having appwrite on a subdomain in the project custom domains? We have an issue with the Appwrite Sites. Sometimes the internal node:dns...
- Incremental/Updates based on OG value wh...
I've set up my own SDK accessed as below ```lua DB["userinfo"]["bankaccounts"]:update({ method = "equal", attribute = "userid", values =...
- Problem while creating new jwt token in ...
I have a component that creates new jwt every 14sec but it seems to not be working , also not sure if that is the best way to do it
