I'm building a new application, and once I build the application, I get a Not allowed to load local resource: file:///C:/App%20Name/resources/app.asar/assets/html/tasks/addtask.html error. I can open up the app, and goto the assets/html/verify.html/ and the assets/html/tasks/tasks.html/ folder, but none of the others. I have no idea why.

Everything works fine in development, but only some in production.

This is what i've tried: disabling web security, using setTimeout to wait for window to load, and I've also tried loading assets/html/tasks/addtask.html on startup, with no success.

This is what my index.js file loads:

const HTML_DIR = '/assets/html/'
ipcMain.on('tasks:add', () => {
    winAddTask = new BrowserWindow({
        width: 800,
        height: 660,
        frame: false,
        webPreferences: {
            webSecurity: true
        }
        // resizable: false,
    });

    winAddTask.openDevTools({ detach: true });

    winAddTask.loadURL(url.format({
        pathname: path.join(__dirname, HTML_DIR, 'addtask.html'),
        protocol: 'file:',
        slashes: true
    }));


});```

I expect it to load `assets/html/tasks/addtask.html` when sending `tasks:add` but it is not. Thank you!

0 Answers