react-native-wkwebview
react-native-wkwebview copied to clipboard
Should set web view's config "allowFileAccessFromFileURLs" to true
like this;
[_webview.configuration.preferences setValue:@(true) forKey:@"allowFileAccessFromFileURLs"];
So when load local file, it can access all the resources in "allowingReadAccessToURL" folder.
In my project, the js code (loaded by the web view) reference one html file. If not set the config "allowFileAccessFromFileURLs", the html file can not be accessed with the error: "XMLHttpRequest cannot load the referenced html file path. Cross origin requests are only supported for HTTP."
Have you tried setting this prop in source
: source={{file: '', allowingReadAccessToURL: '' }}
Could be similar issue to this.
In my HTML files, I load bundle.js using <script src="bundle.js"></script>
the js file doesn't seems to run
here's my code
source={{ file: RNFS.MainBundlePath + '/index.html', allowingReadAccessToURL: RNFS.MainBundlePath}}
And I've checked the RNFS.MainBundlePath, both index.html and bundle.js are in there
@boundaryfree can you create a pull request?
@boundaryfree @insraq @JakeRawr @InternetExplorer8 any luck? I also need to use - allowFileAccessFromFileURLs
And
source={{ file: RNFS.MainBundlePath + '/index.html', allowingReadAccessToURL: RNFS.MainBundlePath}}
Its NOT WORKING. :(