Skip to content

Commit

Permalink
fix: Add baseUrl can fix localstorage not working
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Feb 9, 2024
1 parent 970946d commit ea4014d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/WikiWebView/WikiViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<!doctype html><html lang="en"><head><meta charset="UTF-8" /></head><body><div id="tidgi-mobile-webview-before-loaded-place-holder"/></body></html>` }}
source={{
html: `<!doctype html><html lang="en"><head><meta charset="UTF-8" /></head><body><div id="tidgi-mobile-webview-before-loaded-place-holder"/></body></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) => <Text>{errorName}</Text>}
renderLoading={() => <Text>{t('Loading')}</Text>}
Expand Down

0 comments on commit ea4014d

Please sign in to comment.