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

Access-Control-Allow-Headers

    XMLWordPrintableJSON

    Details

      Description

      Hello,

      I have one app with:

      Cordova version: 8.0.0

      cordova-ios version: 4.5.4

      I had to install the plugin "cordova-plugin-wkwebview-engine" to solve a problem with the interface.

      In android everything works correctly.

      But in IOS when I make AJAX requests to my API I have the error:

       

      XMLHttpRequest cannot load ....... Request header field Authorization is not allowed by Access-Control-Allow-Headers

       

      In the API I have the following in place to allow CORS connections:

      header('Access-Control-Allow-Headers: *');
      header('Access-Control-Allow-Origin: *'); 
      header('Access-Control-Allow-Methods: *');
      

      In the config.xml I have this:

      <access origin="*" />
      <allow-intent href="http://*/*" />
      <allow-intent href="https://*/*" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      
      <feature name="CDVWKWebViewEngine">
      <param name="ios-package" value="CDVWKWebViewEngine" />
      </feature>
      
      <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

      and my AJAX requests are:

      $.ajax({
        url: url,
        data: formData,
        type: 'post',
        dataType: "json",
        contentType: false,
        processData: false,
        success: function (respuesta) {
        }
      });
      

      And I have this meta:

      <meta http-equiv="Content-Security-Policy" content="default-src * gap:;font-src 'self' data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; media-src *; img-src * filesystem: data:">
      

      The strange thing is that without the plugin(cordova-plugin-wkwebview-engine) it works fine, but I need the plugin obligatorily.

      I am desperate and I do not know what to do anymore.
      any solution?

        Attachments

          Activity

            People

            • Assignee:
              surajpindoria Suraj Pindoria
              Reporter:
              alebupal Alejandro
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: