Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-10127

Internal XMLHttpRequest Error calling rest API from Android release build



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: cordova-android, cordova-js
    • Labels:
    • Environment:

      Node JS, cordova whitelist plugin, android release build, hybrid app


      I have an android build that works well in debug builds, but, gives me 'Internal XMLHttpRequest Error' when I run it using an Android release build (I'm using console.log through an NPM module along with adb logcat to monitor the logs).

      Here's the set up that I have:

      • single page hybrid app with following in index.html
        <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
      • cordova whitelist plugin being used. Following settings in config.xml
        <plugin name="cordova-plugin-whitelist" spec="^1.1.0" />
        <access origin="*" />

      The app uses crosswalk to render content - it's a node JS, react app.

      On startup, the app hits a CGI hosted on an HTTP server to get JSON data - this works well in debug and in release mode.

      The app then hits REST APIs on HTTPS - this works well in debug but fails in release builds with the 'Internal XMLHttpRequest Error'.

      The REST API call does not make it out of the phone and never hits the server, so, I assume that the problem is security related on the handset. I have tried all sorts of combinations of settings in my config.xml and in my index.html to loosen security/CSP and still see the problem with the 'relaxed' settings I have pasted in the ticket.

      Plugins that I am using:

          <plugin name="cordova-plugin-device" spec="^1.0.0" />
          <plugin name="cordova-plugin-splashscreen" spec="^2.0.0" />
          <plugin name="cordova-plugin-statusbar" spec="^1.0.0" />
          <plugin name="cordova-plugin-whitelist" spec="^1.1.0" />
          <plugin name="cordova-sqlite-storage" spec="^0.7.13" />
          <plugin name="cordova-plugin-x-toast" spec="~2.2.1" />
          <plugin name="cordova-plugin-x-socialsharing" spec="~5.0.5" />
          <plugin name="phonegap-plugin-push" spec="^1.4.0" />
          <plugin name="cordova-plugin-console" spec="^1.0.1" />
          <plugin name="cordova-plugin-dialogs" spec="~1.1.1" />
          <plugin name="cordova-plugin-app-version" spec="~0.1.7" />

      Here's the generated config from the Android res/xmml directory:

          <preference name="loglevel" value="DEBUG" />
          <feature name="PushPlugin">
              <param name="android-package" value="com.plugin.gcm.PushPlugin" />
          <preference name="webView" value="org.crosswalk.engine.XWalkWebViewEngine" />
          <preference default="15+" name="xwalkVersion" />
          <preference default="--disable-pull-to-refresh-effect" name="xwalkCommandLine" />
          <preference default="embedded" name="xwalkMode" />
          <preference default="true" name="xwalkMultipleApk" />
          <feature name="Device">
              <param name="android-package" value="org.apache.cordova.device.Device" />
          <feature name="Notification">
              <param name="android-package" value="org.apache.cordova.dialogs.Notification" />
          <feature name="SplashScreen">
              <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
              <param name="onload" value="true" />
          <feature name="StatusBar">
              <param name="android-package" value="org.apache.cordova.statusbar.StatusBar" />
              <param name="onload" value="true" />
          <feature name="Whitelist">
              <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
              <param name="onload" value="true" />
          <feature name="SocialSharing">
              <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
          <feature name="Toast">
              <param name="android-package" value="nl.xservices.plugins.Toast" />
          <feature name="SQLitePlugin">
              <param name="android-package" value="io.liteglue.SQLitePlugin" />
          <feature name="PushNotification">
              <param name="android-package" value="com.adobe.phonegap.push.PushPlugin" />
          <feature name="AppVersion">
              <param name="android-package" value="uk.co.whiteoctober.cordova.AppVersion" />
      <....snip....removed app specific details...>
          <content src="index.html" />
          <preference name="DisallowOverscroll" value="true" />
          <preference name="SplashScreen" value="screen" />
          <preference name="SplashScreenDelay" value="10000" />
          <preference name="AutoHideSplashScreen" value="false" />
          <preference name="Orientation" value="portrait" />
          <preference name="xwalkVersion" value="15+" />
          <preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect" />
          <preference name="xwalkMode" value="embedded" />
          <preference name="xwalkMultipleApk" value="true" />
          <access origin="*" />
          <allow-intent href="tel:*" />
          <allow-intent href="geo:*" />

      Has anybody had the same problem or can anybody suggest a workaround/fix?




            • Assignee:
              allymacmac alastair
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: