Development, JavascriptElectron Error: Not allowed to load local resource

Electron Error: Not allowed to load local resource

I’ve recently begun playing with Electron (the library that lets you build cross-platform desktop apps with web technologies). And not long into trying to hook up my default HTML page I received this error:

Not allowed to load local resource

I was certain I’d typed the line to load the URL just like the tutorial suggested. I searched around and was having trouble finding out why my app wasn’t working. Finally, in a reply buried in the comments was the answer. I was using single quotes and what I needed was the back tick for my value passed.

I had this

mainWindow.loadURL('file://${__dirname}/countdown.html');

But needed this

mainWindow.loadURL(`file://${__dirname}/countdown.html`);

It’s an incredibly easy thing to not notice, but because I was dynamically swapping out the ${__dirname} variable, I had to use the back ticks (`) and not the single quote (‘).

Hopefully that will help other Electron beginners experiencing the same issue.

Categories: Development, Javascript Tags: , , ,

Comments

No Comments Yet. Be the first?

Post a comment

Your email address will not be published. Required fields are marked *