capacitor-community / http

Community plugin for native HTTP
MIT License
208 stars 136 forks source link

Unable to open asset URL on Android #279

Open Endi327 opened 2 years ago

Endi327 commented 2 years ago

Describe the bug

I'm building an ionic application and I faced with an issue that affect only the Android devices.

I have some public images that I'd like to load like this:

I'm using this plugin to make API calls, to avoid CORS issues. All the API calls are working on both platforms, but the images only works on iOS.

If I check the inspector this is the error message I get:

Screenshot 2022-09-06 at 12 17 00

If I check the Android Studio logs I see these error messages: E/Capacitor: Unable to open asset URL:

If I'm using axios to make the API calls it works fine on Android but then it'll break on iOS due to CORS issues.

I was trying to separate the API calls and only use the native plugin on iOS but I don't think that is possible.. Android was able to make the calls with axios but even it says 200 OK, the response is always like this instead of JSON:

Screenshot 2022-09-06 at 12 29 44

Android AndroidManifest is extended with this: android:usesCleartextTraffic="true"

webDir: "build", bundledWebRuntime: false, android: { allowMixedContent: true }, server: { cleartext: true, hostname: "baseurl.hu", iosScheme: "localhost", androidScheme: "https" },

To Reproduce Steps to reproduce the behavior:

  1. Add this plugin to your project
  2. Try to load external public images into an image
  3. on iOS it loads well, on Android it does not.

Expected behavior Images should load on both platform. I tried to load other public images and non of them worked for me. When I was using axios it worked fine.

Smartphone (please complete the following information):

Additional context I would be okay with both solutions, use axios on Android and native network calls for iOS OR make Android load images somehow.