A. Khaled
A. Khaled

Reputation: 1608

Ionic - E/Capacitor: Unable to open asset URL

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'
    ]
  }
}

Upvotes: 1

Views: 5147

Answers (1)

A. Khaled
A. Khaled

Reputation: 1608

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"
  }
}

Upvotes: 1

Related Questions