I have a problem after I have built and published my Flutter Web App. My app is working perfectly when running it from the IDE , Android Studio, with Google chrom in Localhost:somePort.
What I have done: --- I have published my app to my web server and it is working on the web-site with my domain, i.e. www.mysite.com --- I have created a custom domain in Appwrite console settings for my Appwrite app as ar.mysite.com , --- I created A record in the DNS settings of domain, the console of Appwrite is accessible through the browsert at https://ar.mysite.com --- I have created an SSL certification on the Appwrite server according to the docs. --- I have also changed the Endpoint of Appwrite in my Flutter app to point to the new address: https://ar.mysite.com/v1 --- I have modified the .env file in appwrite folder of the Appwrite server
and still after all that , I can open the app in the browser, but is stops running when getting to authentication request from the server and the browser's console gives me a CORS error as follows:
Access to XMLHttpRequest at 'https://ar.mysite.com/v1/account?#' from origin 'https://mysite.com' 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.
any help will be appreciated. Guy
Did you add your domain as a platform in Appwrite console?
I mean the new domain through which you're accessing your Appwrite endpoint in production mode
Thank you for the response , Yes , I have added *.mysite.com as a flutter web platform
In your error message, it says mysite.online
sorry for that , just a typo, I fixed it, the error from the browser is giving the right url
you probably understand , for security reasons, I have changed the url to 'mysite.com', missed this one.....
although, stangely, it also giving a https://localhost , which I could not figure out...
@Samuel Kings Any other Idea?
I'm not really sure. Let's wait for the Appwrite support team.
Thanks Samuel, appreciate your help, waiting.......
No problem
@YahalomS you can also join stage channel for office hours, the team might be able to help
Taking this up in OH right now and this is what we discussed:
- You need to add the web platform instead of flutter-web
It works!
Thank you @YahalomS for bringing this up and joining Office Hours :appwriteheart2:
Thanks alot friends in OH!
[SOLVED] Flutter web and appwrite CORS problem
Recommended threads
- Which flutter SDK version for Self Hoste...
Hi all, Is there a good way to figure out which version of flutter SDK and Dart SDK is current for latest available self-hosted 1.8.0 ? I know new features are...
- Google Auth not working in a React App
Authentication with Google has failed. It redirects back to the signin route in React. Attached screenshots for configuration of Google console and Appwrite Go...
- Bug Report: Crash when trying to createR...
https://github.com/appwrite/sdk-for-android/issues/96 I think the bug is related with this one https://discord.com/channels/564160730845151244/1443887021314539...