CRAlpha / CRAlpha/react-native-wkwebview

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

Open
#106 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
637
Forks
263
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating where the WKWebView configuration and preferences are set, then trace the local-file loading path described in the issue. Verify that enabling allowFileAccessFromFileURLs lets JavaScript-loaded HTML access resources within the allowingReadAccessToURL folder, without the reported cross-origin error.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.