Ajax calls are not working only in release builds but are fine in debug builds. I'm doing all calls over https. There are no CORS error. Note that the issue only appears on Android, not on iOS.
I use Let's Encrypt
SSL certs on the back end.
SHA256withRSA
I have tried EVERY fix available on SO:
<plugin name="cordova-plugin-enable-cleartext-traffic" space="^2.1.0" />
I verified that I have android:usesCleartextTraffic="true"
in manifest in the application node
I have added to config.xml
<access origin="*" />
<allow-navigation href="*" />
<preference name="AndroidInsecureFileModeEnabled" value="true" />
and also
<edit-config xmlns:android="http://schemas.android.com/apk/res/android" file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
And in res/xml
created a file network_security_config.xml
with content
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">mydomain.com</domain>
</domain-config>
</network-security-config>
I have verified that my Let's Encrypt
SSL certificate is valid, it is. I do not have whitelist plugin anymore due to Android 10
Version are
Cordova Android 10.1.1
Cordova 10.0.0
Tested on real device running Android 6.0.1 (have to support older phones)
Nothing works. Please help
CodePudding user response:
You should check if you get any CORS erros. If you run your app on file:
you might need AndroidInsecureFileModeEnabled
in config.xml
I suggest you to use the WebViewAssetLoader with cordova-android@10. Please check out the announcement https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html
CodePudding user response:
I will answer my own question, it might save someone A LOT of time. The issue is that I'm using let's encrypt SSL certificates and I had been testing on Android 6.1.0. Following this post I just noticed that Let's Encrypt SSL certificates will not work anymore on Android < 7.1.1
Tested on Android 11 and it just worked.