I originally had only 1 platform set up - localhost. I tried adding a second platform with my actual domain but when I tried logging in I got a cors error.
I then tried editing my localhost platform to my domain, and it still allowed me to log in on my local dev.
When I change both platforms to my domain, in the error message there is still a reference to localhost:
Access to XMLHttpRequest at 'https://cloud.appwrite.io/v1/account/sessions/email' from origin 'https://www.mydomain.co.uk' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost' that is not equal to the supplied origin.
Is there a delay in changes taking effect?
Uh, not sure, but tried doing this and I don't get lag or anything
It seems like my account isn't updating then
Are you getting more errors apart from CORS?
No errors. I have just deleted both platforms from my account, so there are none, and it is still letting me log in. That can't be right can it?
Uh usually login is not affected/protected by cors
Just to double check I commented out the setEndpoont and setProject lines in my app and only then it failed (as expected)
Could you please send here the code it's giving you the errors?
my login component (React Next)
To reiterate, everything works fine locally and I can log on to my app using the AppWrite cloud.
When I try to log on from my deployed app I get:
Access to XMLHttpRequest at 'https://cloud.appwrite.io/v1/account/sessions/email' from origin 'https://www.growthpathways.co.uk' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost' that is not equal to the supplied origin.
And this is whether I have no platforms added, or a localhost platform, or platform specifying my domain.
I do not get any other errors from code.
have you tried deleting the cache in cloud?
not sure what the issue is, but worth a try i guess?
i've deleted browser cache, how do i delete cache in cloud?
Yes that's what I meant, sorry!
Did that fix the issue by any chance?
no it didn't
Are you using any kind of server side rendering?
localhost works by default.
any other web app will require a platform set.
Would you please look at network logs in your browser and share the request headers?
i had same cors issue today and after much hair pulling i had the wrong project id. Works fine again now
Weird, the problem has developed a little bit. I eventually got it working on my domain, however as soon as I applied Let's Encrypt free SSL certificate the Cors error is back.
This is my server config:
server {
server_name growthpathways.co.uk www.growthpathways.co.uk;
location / {
proxy_pass http://localhost:3000; # Assuming your Next.js app runs on po>
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/growthpathways.co.uk/fullchain.pem; # >
ssl_certificate_key /etc/letsencrypt/live/growthpathways.co.uk/privkey.pem; >
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.growthpathways.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = growthpathways.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name growthpathways.co.uk www.growthpathways.co.uk;
return 404; # managed by Certbot
}
This is my error:
Access to XMLHttpRequest at 'https://cloud.appwrite.io/v1/account/sessions/email' from origin 'https://www.growthpathways.co.uk' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://localhost' that is not equal to the supplied origin.
Also works fine logging in from localhost, or from my servers IP address (I have 3 platforms set up on AppWrite for localhost, server IP, and domain)
It's ok I have just tried it on another device and it worked so maybe the new issues is a caching problem on my laptop.
Thanks everyone for the help. I can't 100% say what the error was but I think there was some issue with the build and a mix up of Project ID's like Tigertek somewhere down the line too
Recommended threads
- Error With iOS Apps
I keep getting the below errors for my flutter app. The clients are registered and have been. This wasn't an issue a few hours ago. AppwriteException: AppwriteE...
- Backup policies think im on free tier
Cant create more than one policy as im told to ugprade, when clicking upgrade im taken to the upgrade page which confirms im already on pro
- Cant get rid of "get started"
Not that important, but annoying. No matter what I do I cant get the "Get started" to go away, ive added a bunch of web platforms and its just stuck.