0

I have a simple Cordova app that's loads a webview with my website url. The problem is that the site is not yet in production so i need to use the http://example.test instead of https://example.com for local development.

I tried to put the local url in the webview open method:

cordova.InAppBrowser.open('http://example.test');

But it gives me the following error:

Application Error. net::ERR_CLEARTEXT_NOT_PERMITTED (http://example.test/)

Is the only solution to this problem to upload a pre-production site? I couldn't find any options/plugins to use a local domain in a webview.

Ricki
  • 81
  • 11

1 Answers1

0

Since Android 9 (Pie), you are not able to connect to http:// sites anymore. Here is a blogpost about it.

To fix it:

In your AndroidManifest you have to add android:usesCleartextTraffic="true"

For example you can add this to your config.xml

<widget xmlns:android="http://schemas.android.com/apk/res/android" ...>

<platform name="android">
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:usesCleartextTraffic="true" />
    </edit-config>
    ...
</platform>

If you do it like this, you have to add the schema xmlns:android="http://schemas.android.com/apk/res/android" to your <widget> -tag. See this answer for reference.

Community
  • 1
  • 1
Michael B
  • 1,660
  • 3
  • 28
  • 59