Failed to fetch api on android device (browser ok)

Hi,

When I run my ionic 4 app in the browser , fetch works and retrieves the GET result from my express nodejs server.
On my android device, it seems the api is not even called and I get TypeError: Failed to fetch.
I enabled cors on my express server
My server is running http (not https), is that why?
Thank you for your help,
Bruce
PS: firebase doesn’t work either
PS: it works fine in a android emulator

There’s not a lot to go off of from this. If you attach chrome dev tools, can you see what error could be there in the console?

Using Chrome dev tools, I get:
Failed to load resource: net::ERR_CLEARTEXT_NOT_PERMITTED

To stay in http, it works by adding a file called network_security_config.xml

<network-security-config>
  <!--Set application-wide security config using base-config tag.-->
  <base-config cleartextTrafficPermitted="true"/>
</network-security-config>
  


In AndroidManifest.xml 
android:networkSecurityConfig="@xml/network_security_config"

There might be other options.
Thank you,
Bruce

the problem is due to the fact that by default ionic does not allow http connections … so to overcome this problem, add to the AndroidManifest.xml file located in /android/app/src/main as follows

<application 
    android:usesCleartextTraffic="true"
>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


permission