'My Cordova app works fine on iOS and Android debug but won't connect to its REST server in Android release mode

I've been developing this app under various guises for some time now but when trying to release the most recent version, it fails to connect to the backend REST server when I build an Android release version for the Play Store. This has only happened since Google stopped accepting .apk builds and insisted on app bundles. I've researched numerous solutions on Stack Overflow but none seem to apply to my situation. The REST server communicates via HTTPS on port 8443 and the certificate for this port is from a mainstream certificate authority. Here's the relevant sections of my config.xml file:

    <content src="index.html" />
    <access origin="https://www.samoperational.co.uk" />
    <allow-intent href="https://www.samoperational.co.uk/*" />
    <icon src="icon.png" />    
    <splash src="splashscreen.png" />
    <preference name="Orientation" value="portrait" />
    <config-file target="AndroidManifest.xml" parent="/*" mode="merge">
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.INTERNET" />
    </config-file>
    <platform name="android">
        <preference name="AndroidXEnabled" value="true" />
        <preference name="android-targetSdkVersion" value="30" />
        <preference name="AndroidPersistentFileLocation" value="Compatibility" />
        <preference name="android-build-tool" value="gradle" />
        <allow-intent href="market:*" />
        <preference name="splashscreen" value="splashscreen" />
        <preference name="splashScreenDelay" value="10000" />
    </platform>
    <platform name="ios">
        <preference name="scheme" value="app" />
        <preference name="hostname" value="localhost" />        
    <preference name="target-device" value="handset" />
        <icon height="20" src="icons/Icon20x20.png" width="20" />
        <icon height="40" src="icons/Icon40x40.png" width="40" />
        <icon height="180" src="icons/Icon180x180.png" width="180" />
        <icon height="80" src="icons/Logo_80x80.png" width="80" />
        <icon height="120" src="icons/Icon120x120.png" width="120" />
        <icon height="1024" src="icons/Logo_1024x1024.png" width="1024" />
        <splash height="2436" src="icons/SplashScreen1125x2436.png" width="1125" />
        <splash height="1136" src="icons/SplashScreen640x1136.png" width="640" />
        <splash height="1334" src="icons/SplashScreen750x1334.png" width="750" />
        <splash height="2208" src="icons/SplashScreen1242x2208.png" width="1242" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <edit-config target="NSLocationAlwaysUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Location not used by LionRidge</string>
        </edit-config>
        <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Location not used by LionRidge</string>
        </edit-config>
        <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Camera only used for bar code reading when selecting an alternate server</string>
        </edit-config>
        <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="overwrite">
            <string>Photo library not used by LionRidge</string>
        </edit-config>
    </platform>

However, although the intention of the access origin and allow-intent directives was to restrict the app to only connect to my own server, I have found the following contradictory lines later in the config file:

    <access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />
    <allow-navigation href="file:*" />


Solution 1:[1]

Adding

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

to config.xml fixed the problem for some reason I am not understanding

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cribo