react-native-wkwebview icon indicating copy to clipboard operation
react-native-wkwebview copied to clipboard

Should set web view's config "allowFileAccessFromFileURLs" to true

Open boundaryfree opened this issue 7 years ago • 4 comments

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."

boundaryfree avatar Dec 21 '17 09:12 boundaryfree

Have you tried setting this prop in source: source={{file: '', allowingReadAccessToURL: '' }}

insraq avatar Feb 20 '18 06:02 insraq

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

JakeRawr avatar Mar 22 '18 19:03 JakeRawr

@boundaryfree can you create a pull request?

InternetExplorer8 avatar May 22 '18 20:05 InternetExplorer8

@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. :(

shoebhoney avatar Mar 31 '20 15:03 shoebhoney