DEV Community

Lukas Gaucas
Lukas Gaucas

Posted on

Content-Security-Policy (CSP) warning in Electron – how to disable it?

There might be plenty of reasons why we do not want to defined stuff within package.json one one them – flexibility, dedication for yoga ? Hmm maybe , whichever the reason would be let's go remove CSP warning – there least two ways to do so :


Disable through CLI

Consider running Electron's app source file main.js within CLI as so: ELECTRON_DISABLE_SECURITY_WARNINGS=true npx electron main.js

Hereby using npx I did consider you was clever and installed Electron locally beforehand .

Disable through the process

Define anywhere (top-level would be at best) the following

process.env['ELECTRON_DISABLE_SECURITY_WARNINGS']=true
Enter fullscreen mode Exit fullscreen mode

Useful references

Top comments (0)