Back

[SOLVED] CORS error in Flutter Web App

  • 0
  • Self Hosted
  • Flutter
  • Web
tahakhawaja
16 Aug, 2023, 06:51

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.

TL;DR
The user faced a CORS error in their Flutter Web App. They were advised to add a web platform with the hostname instead of the IP address. The issue was resolved after making this change. There was no need to update the Appwrite backend.
safwan
16 Aug, 2023, 06:57

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

tahakhawaja
16 Aug, 2023, 06:58

If it's already been done previously, how can I update it?

safwan
16 Aug, 2023, 06:59

You can just click on the platform and update the value of the hostname

safwan
16 Aug, 2023, 07:00

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

tahakhawaja
16 Aug, 2023, 07:00

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.

safwan
16 Aug, 2023, 07:02

Ah in that case, you might have to delete this platform, and create a new one for Web instead

tahakhawaja
16 Aug, 2023, 07:03

So no need for the one that's currently there? Just do web app alone?

safwan
16 Aug, 2023, 07:03

Yepp. Just a web app will do!

tahakhawaja
16 Aug, 2023, 07:04

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?

safwan
16 Aug, 2023, 07:05

No need for that! Just add the platform and you should be good to go!

safwan
16 Aug, 2023, 07:05

Let me know if you still face issues

tahakhawaja
16 Aug, 2023, 07:12

It seems to be working, thank you for the help Safwan!

safwan
16 Aug, 2023, 09:49

[SOLVED] CORS error in Flutter Web App

Drake
18 Aug, 2023, 00:45

does it work if you delete the regular web platform and add a flutter web with the hostname instead of the IP?

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