Ade Ade - 1 month ago 27x
iOS Question

Cordova 6 app cannot load from file:// path

I have updated an existing app to Cordova 6.0.0 and am having problems running it on an iOS device with XCode 7.2.1 targeting iOS 9.

I have installed the WKWebView plugin:

cordova-plugin-wkwebview-engine 1.0.2

When running the app, which is built with AngularJS, one of the first things it tries to do is open a json file:

$http.get('data/config.json').success(function(data) {
// do stuff

But we get this error in the web view console:

XMLHttpRequest cannot load file:///var/mobile/Containers/Bundle/Application/
E9D74C94-ADC6-410F-9F41-7CE63CB7877F/ Cross
origin requests are only supported for HTTP.

In the config.xml file we have:

<access origin="*" subdomains="true" />

Why is the file:// request being blocked like this and how can I fix it?


According to the plugin page:

"In iOS 9, Apple has fixed the issue present through iOS 8 where you
cannot load locale files using file://, and must resort to using a
local webserver. However, you are still not able to use XHR from the
file:// protocol without CORS enabled on your server."

What do they mean by "your server"? What server? We are loading a local file, there is no server!


This is a known issue, local file:// url XmlHttpRequests are not allowed in WKWebViewEngine (

For more known issues see

If you want to make local ajax call to work you should use the wkwebview-engine-localhost plugin (

Or Telerik's WKWebView plugin (

Both of them will use a local webserver that solves some of the known WKWebView limitations.