This is the error that I get in development
Not allowed to load local resource: file:///C:/Users/first.last/Documents/ElectronApp/public/icon.png
This is what I get in production
Not allowed to load local resource: file:///C:/Users/first.last/AppData/Local/Programs/ElectronApp/resources/app.asar/icon.png
I am trying to show a notification from the renderer process and it takes in an icon string parameter so I am passing it ${__static}\\icon.png, but I keep getting the error above. Anyone know how I can go about fixing this (the icon is in my public folder)?
Can you explain how you fixed the issue so that others with the same problem can fix it for themselves?
My colleague figured it out. He said that for security reasons (when webSecurity is on), electron won't/shouldn't let you load a file "directly" from disk (i.e. a file path like the 2 URIs in my previous post) so he said to import it so that webpack resolves the path to somewhere in the bundle.
import icon from '../public/icon.png';
new Notification(title, { icon, requireInteraction: true });
Most helpful comment
My colleague figured it out. He said that for security reasons (when webSecurity is on), electron won't/shouldn't let you load a file "directly" from disk (i.e. a file path like the 2 URIs in my previous post) so he said to import it so that webpack resolves the path to somewhere in the bundle.