Webview – allow to load local resources when using data URLs

  • using Atom shell 0.19.5 with the webview tag
  • set the src attribute of the webview to a data URL that has a reference to a local resource (e.g. image tag)
  • open the app and listen to the console-message event on the webview
    => Not allowed to load local resource: file:///C://1.jpg

It would be nice if for a webview you could bypass this security measure when you set a data URL.

My app html:

<!DOCTYPE html>
    <title>Hello World!</title>
    <h1>Hello World!</h1>
    We are using node.js <script>document.write(process.version)</script>
    and atom-shell <script>document.write(process.versions['atom-shell'])</script>.

    <webview id="foo" src="data:text/html;base64,<BASE 64 encoded>" style="width:640px; height:480px"></webview>

    <script type="text/javascript">
        document.getElementById("foo").addEventListener("console-message", function(e) {

The base 64 encoded value is something like:

<img src="file:///path to app/1.jpg" />

1 thought on “Webview – allow to load local resources when using data URLs

Comments are closed.