I am building an Android app using Cordova, that runs on Android 8.1. This app will be used in a LAN only and it needs to consume data from a local REST Webserver over HTTP… but because Android 8 forces Ionic apps to run under HTTPS, I am getting an error when trying to access the REST server over HTTP.
By doing some research, I discovered that the solution is to change WebView settings to allow mixed content. There were several ways to do this, but the easiest one was to add this line to my Ionic’s config.xml:
<preference name="MixedContentMode" value="2" />
According to documentation, the posibles values for this setting would be:
0: MIXED_CONTENT_ALWAYS_ALLOW 1: MIXED_CONTENT_NEVER_ALLOW 2: MIXED_CONTENT_COMPATIBILITY_MODE
First time I tried the app after adding this line, everything worked perfectly, but the next time I compiled and deployed the app, I got the same error again:
Mixed Content: The page at ‘https://localhost/config’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://192.168.0.5:5656/’. This content should also be served over HTTPS.
Anyone know how to permanently solve this?
My versions are:
PS #1: For compatibility reasons with the devices where the app should run, I HAVE to use these versions, so updating any of them is out of the question.
PS #2: Since this app will run in LAN exclusively, my customer don’t want to deal with the complications of moving the REST webservice to HTTPS, so that’s is out of the question too.