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