Ionic - E/Capacitor: Unable to open asset URL

4.3k views Asked by At

I can't load any image from external url in real device. I am always getting the following error:

enter image description here

This is my capacitor.config.json

{
  ...,
  server: {
    cleartext: true,
    hostname: "rootsmenu.com",
    allowNavigation: [
      'localhost',
      'rootsmenu.com'
    ]
  }
}
1

There are 1 answers

4
A. Khaled On

I edited capacitor.config.ts with following configs and it worked! Also, I was editig the wrong file android/app/src/main/assets/capacitor.config.json. Because it was replaced with capacitor.config.ts content each time I ran npx cap sync android

capacitor.config.ts

{
  ...
  "android": {
    "allowMixedContent": true
  },
  "server": {
    "cleartext": true,
    "hostname": "localhost"
  }
}