From ea4014d0b177cd4558090383c42dc6cfe0d5104b Mon Sep 17 00:00:00 2001 From: linonetwo Date: Fri, 9 Feb 2024 22:49:28 +0800 Subject: [PATCH] fix: Add baseUrl can fix localstorage not working fixes #39 close https://github.com/react-native-webview/react-native-webview/issues/3324 --- src/pages/WikiWebView/WikiViewer.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/WikiWebView/WikiViewer.tsx b/src/pages/WikiWebView/WikiViewer.tsx index 43422e8..df13ccb 100644 --- a/src/pages/WikiWebView/WikiViewer.tsx +++ b/src/pages/WikiWebView/WikiViewer.tsx @@ -145,7 +145,14 @@ export const WikiViewer = ({ wikiWorkspace, webviewSideReceiver, quickLoad }: Wi allowsFullscreenVideo userAgent={FAKE_USER_AGENT} // add DOCTYPE at load time to prevent Quirks Mode - source={{ html: `
` }} + source={{ + html: `
`, + /** + * Add baseUrl to fix `SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.` + * @url https://github.com/react-native-webview/react-native-webview/issues/1635#issuecomment-1021425071 + */ + baseUrl: 'http://localhost', + }} // source={{ uri: 'about:blank#%E6%9E%97%E4%B8%80%E4%BA%8C:%E6%9E%97%E4%B8%80%E4%BA%8C%20Index' }} renderError={(errorName) => {errorName}} renderLoading={() => {t('Loading')}}