Skip to content
Back

[SOLVED] Flutter Web - AppwriteException: null, XMLHttpRequest error. (0)

  • 0
  • Users
  • Flutter
  • Web
Drake
1 Apr, 2023, 03:19

Did you put only the hostname of your flutter app with no leading it trailing spaces?

TL;DR
The issue is with a self-signed certificate on the Appwrite instance causing an XMLHttpRequest error. The solution is to switch to using an https endpoint and ensure the content is served over HTTPS. The issue may also be related to CORS policy. Full logs from the browser console would be helpful for further troubleshooting.
Drake
1 Apr, 2023, 03:23

Would you please share the full logs from the browser console?

Arrow
1 Apr, 2023, 03:33

Yes, and since it's firebase hosting, the link looks like myapp.web.app. so I just put that in the hostname when adding flutter web platform

Arrow
1 Apr, 2023, 03:36

Could you elaborate a little more?

Drake
1 Apr, 2023, 03:37

Browser dev tools

Arrow
1 Apr, 2023, 03:40

I do see this ed Content: The page at 'https://myapp.web.app/#/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://XXX/v1/account/sessions/email'. This request has been blocked; the content must be served over HTTPS.

Arrow
1 Apr, 2023, 03:40

though I tried calling over https as well,

Drake
1 Apr, 2023, 03:42

Please switch to https for your endpoint and share the new logs

Arrow
1 Apr, 2023, 03:47
TypeScript
main.dart.js:38098
POST https://XXX/v1/account/sessions/email net::ERR_FAILED``` I notice that now over an https my antivirus blocks the connection!
Arrow
1 Apr, 2023, 03:49

I can somehow establish a connection now, but as soon as it happens the browser treats my app as insecure even tho it's on https

Arrow
1 Apr, 2023, 03:51
Arrow
1 Apr, 2023, 03:54

that happens after appwrite's auth, I wonder if this is supposed to be like that or am missing something

Drake
1 Apr, 2023, 03:57

What do the details say when you click on Not Secure

Arrow
1 Apr, 2023, 03:59

this popup

Drake
1 Apr, 2023, 04:00

And if you click on learn more?

Arrow
1 Apr, 2023, 04:03

That's if I'm on chrome, on safari it still throws the same exception as mentioned earlier

Drake
1 Apr, 2023, 04:03

Weird...usually it shows this if certificate is invalid, but it says certificate is valid

Drake
1 Apr, 2023, 04:04

What's showing in the browser console logs?

Arrow
1 Apr, 2023, 04:05

Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint. Just that 🤔

Drake
1 Apr, 2023, 04:09

Not sure then. If you share your URL, I can try to test on my end

Drake
1 Apr, 2023, 04:35

Circling back here...the problem was due to a self signed certificate on the Appwrite instance.

Tomic R.
1 Aug, 2023, 09:26

Hey @Steven! I have the exact same problem. I am hosting my appwrite backend with DigitalOcean and for the web app I am using Firebase hosting. When I am running my web app locally (but the appwrite endpoint is my Droplet from DigitalOcean), it works just fine. But as soon as I am hosting it on Firebase Hosting and accessing it there, I also get XMLHttpRequest error. Can you explain what you mean with self signed certificate on the Appwrite instance and how to solve it?

Drake
1 Aug, 2023, 16:25

please create a new post instead of posting in an old thread

Drake
1 Aug, 2023, 16:25

[SOLVED] Flutter Web - AppwriteException: null, XMLHttpRequest error. (0)

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