Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova iOS Cross origin requests are only supported for HTTP

I'm building an iOS app and recently upgraded cordova-ios to 4.1.0 and started using: cordova-plugin-wkwebview-engine.

The problem is that now I get the error message Cross origin requests are only supported for HTTP while trying to load dependencies, so the app won't start.

It's trying to load systemjs dependencies over file://, but I included in my config.js.

I have no clue how to fix this. Does anyone have experience with this bevaviour?

cordova version: 6.1,0 cordova ios version: 4.1.0

related config.xml bit:

<access origin="*" />
<feature name="CDVWKWebViewEngine">
  <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
like image 727
Sven van de Scheur Avatar asked Apr 06 '16 12:04

Sven van de Scheur


3 Answers

Install this one plugin (cordova-ios 6+)

  cordova plugin add https://github.com/globules-io/cordova-plugin-ios-xhr

then set

  <preference name="AllowUntrustedCerts"  value="true" />
  <preference name="InterceptRemoteRequests" value="all" />
  <preference name="allowFileAccessFromFileURLs" value="true" />
  <preference name="allowUniversalAccessFromFileURLs" value="true" />
like image 57
Eric Avatar answered Sep 28 '22 22:09

Eric


Install the following plugins:

cordova plugin add cordova-plugin-wkwebview-engine    
cordova plugin add cordova-plugin-wkwebview-file-xhr    
cordova plugin add https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix

Add to config.xml:

<platform name="ios">
  ...
   <preference name="WKWebViewOnly" value="true"/>
  ...
 </platform> 
like image 28
Avinash Tribhuvan Avatar answered Sep 28 '22 22:09

Avinash Tribhuvan


For Cordova iOS 6+ just need to install the following plugin.

cordova plugin add https://github.com/AraHovakimyan/cordova-plugin-wkwebviewxhrfix

This plugin does not depend on any other additional plugins and does not require additional permissions.

like image 43
ahovakimyan Avatar answered Sep 28 '22 23:09

ahovakimyan