admin管理员组

文章数量:1352341

I am trying to make an with React and Electron. When I use http, it's working perfectly.

app.on('ready', () => {
  mainWindow = new BrowserWindow({
    titleBarStyle: "hidden",
    width: 1000,
    height: 700,
  });
  mainWindow.webContents.openDevTools();
  mainWindow.loadURL("http://localhost:3000");});

But I need to use the protocol https for my app, so I am writing to run the react script : HTTPS=true npm start. It's running on Chrome with the link https://localhost:3000/. But when I change the mainWindow.loadURL to mainWindow.loadURL("https://localhost:3000") It show a white screen without error in the console.

I am trying to make an with React and Electron. When I use http, it's working perfectly.

app.on('ready', () => {
  mainWindow = new BrowserWindow({
    titleBarStyle: "hidden",
    width: 1000,
    height: 700,
  });
  mainWindow.webContents.openDevTools();
  mainWindow.loadURL("http://localhost:3000");});

But I need to use the protocol https for my app, so I am writing to run the react script : HTTPS=true npm start. It's running on Chrome with the link https://localhost:3000/. But when I change the mainWindow.loadURL to mainWindow.loadURL("https://localhost:3000") It show a white screen without error in the console.

Share Improve this question asked Apr 3, 2018 at 18:38 Monsieur SamMonsieur Sam 3331 gold badge7 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

The issue is because of the certificate error.

Try adding the following lines inside your main.js file.

app.on('certificate-error', function(event, webContents, url, error, 
  certificate, callback) {
      event.preventDefault();
      callback(true);
});

If you want your application to run on https, the ideal solution would be to use the proper certificate.

Hope you find this helpful.

本文标签: javascriptmainWindowloadURL(quothttpslocalhost3000quot) show white screen on Electron appStack Overflow