I have hosted an Appwrite backend on a digital ocean droplet. I also have a flutter front-end website that i have hosted on a separate digital ocean droplet within a docker container. When I currently send requests to my appwrite instance I get these errors:
[Error] Origin http://demo.edventures.ai is not allowed by Access-Control-Allow-Origin. Status code: 403 [Error] XMLHttpRequest cannot load http://178.128.196.153/v1/account due to access control checks. [Error] Failed to load resource: Origin http://demo.edventures.ai is not allowed by Access-Control-Allow-Origin. Status code: 403 (account, line 0)
It seems that these are CORS errors. I have been asked to update CORS settings by adding my front-end website address to the list of allowed origins. How can I do this? I do not see any settings inside of the Appwrite console to do this.
In the Overview tab in your project, scroll all the way down to the Integrations section. If you haven't already, add a web platform with the hostname of your flutter app
If it's already been done previously, how can I update it?
You can just click on the platform and update the value of the hostname
Something to keep in mind is that if your app is Flutter Web App, you will need to add a Web platform.
This was an issue that was brought up before, but use this method for now
When I go down to integrations, there is a platforms section that contains our flutter webapp. When I click the flutter webapp the only options i have are "Name" which is currently set to just "edventures alpha" and the delete platform option that contains "edventures alpha" and the ip address below it.
Ah in that case, you might have to delete this platform, and create a new one for Web instead
So no need for the one that's currently there? Just do web app alone?
Yepp. Just a web app will do!
Thanks Safwan! And is there any need to update the appwrite backend in the digital ocean droplet by running "docker-compose down" and "docker-compose up -d" after making these changes? or can I just continue as is?
No need for that! Just add the platform and you should be good to go!
Let me know if you still face issues
It seems to be working, thank you for the help Safwan!
[SOLVED] CORS error in Flutter Web App
does it work if you delete the regular web platform and add a flutter web with the hostname instead of the IP?
Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...