电子如何允许不安全的 https [英] electron how to allow insecure https

查看:49
本文介绍了电子如何允许不安全的 https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载 https://github.com 可以正常工作.
但是加载不安全的 https,页面显示为空.

Loading https://github.com works fine for exmaple.
But loading an insecure https, the page displays empty.

我做了一些研究并尝试了下面的 3 个标志(webSecurityallowDisplayingInsecureContentallowRunningInsecureContent),但均未成功.

I've done some research and tried the 3 flags (webSecurity, allowDisplayingInsecureContent, allowRunningInsecureContent) below with no success.

寻找任何已知的解决方案.谢谢.

Looking for any known solutions. Thank you.

const { BrowserWindow } = require('electron').remote;

    let win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            plugins: true,
            nodeIntegration: false,
            webSecurity: false,
            allowDisplayingInsecureContent: true,
            allowRunningInsecureContent: true
        }
    });

    win.loadURL('https://insecure...')

推荐答案

main.js 中,做:

const { app } = require('electron')

app.commandLine.appendSwitch('ignore-certificate-errors')

这篇关于电子如何允许不安全的 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆