manish kumar
manish kumar

Reputation: 4702

net::ERR_INSECURE_RESPONSE in Electron

I am trying to connect to the localhost via https. Since on production it will be replaced with a proper IP with a valid SSL, but on localhost it is throwing Error on electron.

enter image description here

How to avoid the error by suppressing the SSL check, just on the localhost for the testing , which i will remove on production.Please help

Upvotes: 2

Views: 7398

Answers (2)

manish kumar
manish kumar

Reputation: 4702

Chris gave an exact explanation. Just posting the code for the same

win = new BrowserWindow({
        width: 900,
        height: 680,
        webPreferences: {
            webSecurity: false
        }
});
//second alternative
app.commandLine.appendSwitch('ignore-certificate-errors');

Upvotes: 13

Chris Riebschlager
Chris Riebschlager

Reputation: 1333

In your BrowserWindow object set webPreferences.allowRunningInsecureContent to true and webPreferences.webSecurity to false. That should suppress those errors.

More info: https://github.com/electron/electron/blob/master/docs/api/browser-window.md

If that doesn't resolve the issue, have a look at this documentation about bypassing certificate errors: https://electronjs.org/docs/api/app#event-certificate-error

Upvotes: 2

Related Questions