Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

CORS - XMLHttpRequest cannot load file:/// URIs #69

Open
rayshan opened this issue Dec 9, 2015 · 2 comments
Open

CORS - XMLHttpRequest cannot load file:/// URIs #69

rayshan opened this issue Dec 9, 2015 · 2 comments

Comments

@rayshan
Copy link

rayshan commented Dec 9, 2015

大家好,

Seems like WKWebView in iOS 8 doesn't support loading content via XMLHttpRequest due to CORS enforcement. In iOS 9 maybe [WKWebView loadFileURL:allowingReadAccessToURL:] can work (reference). I just tried crosswalk-ios 1.2 in iOS 9 and hit this error. Any ideas of how to load local files via files:/// protocol?

@jondong
Copy link
Contributor

jondong commented Dec 9, 2015

@rayshan Thanks for trying Crosswalk. The implementation of [XWalkView loadFileURL:allowingReadAccessToURL:] in iOS 9 is to hook up WKWebView's same api, so it should behave the same as WKWebView. Would you please elaborate or paste your error log here for us to identify the issue? That would be really helpful.

Meanwhile, according to http://www.w3.org/TR/url/#concept-url-scheme, the scheme files:/// is not supported, is it a typo?

@rayshan
Copy link
Author

rayshan commented Dec 9, 2015

My pleasure! No files:/// isn't a typo. This is the error message:

XMLHttpRequest cannot load file:///Users/rayshan/Library/Developer/CoreSimulator/Devices/xxx/data/Containers/Bundle/Application/xxx/crosswalk.app/www/package.json. Cross origin requests are only supported for HTTP.

I think this is a known issue with WKWebView, and the only workaround I can find is to spin up a local server to serve local resources via http. I believe it's the same issue as these:
Telerik-Verified-Plugins/WKWebView#149
https://issues.apache.org/jira/browse/CB-10143

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants