Err_access_denied

Hi,

I get error as below while run project,

Encountered an error loading page, Object {
“canGoBack”: false,
“canGoForward”: false,
“code”: -1,
“description”: “net::ERR_ACCESS_DENIED”,
“loading”: false,
“target”: 159,
“title”: “”,
“url”: “file:///android/dist/index.html”,
}

  • node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
  • … 20 more stack frames from framework internals

Can you post the code you’re using to invoke the Webview?

< WebView style={{ flex : 1 }}
   originWhitelist={["*"]}
    ref = {ref => this.webview = ref }
   injectedJavaScript = { settingChartScript.replace( '{CONFIG}', JSON.stringify( 
   this.props.chartConfiguration ))
   .replace('{DEFAULT_FONT_SIZE}', defaultFontSize )
   }
source= {Platform.OS == 'ios' ? require('./dist/index.html') : {uri: "file:///android/dist/index.html"}}
onError = {(error) => {console.log(error)}}
scalesPageToFit={Platform.OS === 'ios' ? undefined : true}
/>	

I’ve successfully used the following pattern to load an html file into a webview in Expo on Android and iOS in the new react-native-community-webview package


// get the html file
const requiredAsset = require('./dist/index.html');

// load the file at componentDidMount
componentDidMount = async () => {
    try {
      const asset = await AssetUtils.resolveAsync(requiredAsset);
      // console.log({ asset });
      this.setState({ asset });
    } catch (error) {
      console.log({ error });
    }
  };


// in render() create a conditional so that the WebView isn't rendered until the asset is available in state
// once the asset is available you can use it like this:
 source={{ uri: this.state.asset.uri }}

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.