Yes, I understand that accessing HTTP is insecure. But in exceptional situations, sometimes it's necessary to make such a request.
The question is which is the proper way to access http resource from https served app?
Solution 1
When the app is served from http:
<preference name="scheme" value="http" />
<preference name="hostname" value="localhost" />
It is possible to bypass any restriction by adding the following config:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
But it seems that this is the least secure method of all.
Solution 2
cordova-plugin-ionic-webview plugin allows to specify:
// MIXED_CONTENT_ALWAYS_ALLOW
<preference name="MixedContentMode" value="0" />
Android documentation: https://developer.android.com/reference/android/webkit/WebSettings#setMixedContentMode(int)
This allows access to any http domains from the application.
Questions
- Maybe
cordova-android implements the ability to set setMixedContentMode setting?
- Maybe there is some other way to allow access only to selected http domains? To bypass the limitations of both Android itself and WebView.
The question is which is the proper way to access
httpresource fromhttpsserved app?Solution 1
When the app is served from
http:It is possible to bypass any restriction by adding the following config:
But it seems that this is the least secure method of all.
Solution 2
cordova-plugin-ionic-webviewplugin allows to specify:Android documentation: https://developer.android.com/reference/android/webkit/WebSettings#setMixedContentMode(int)
This allows access to any
httpdomains from the application.Questions
cordova-androidimplements the ability to setsetMixedContentModesetting?