Skip to content

How to access http resource from https served app? #505

@mahnunchik

Description

@mahnunchik

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

  1. Maybe cordova-android implements the ability to set setMixedContentMode setting?
  2. Maybe there is some other way to allow access only to selected http domains? To bypass the limitations of both Android itself and WebView.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions