【问题标题】:Electron/electron-packager angular desktop app - http requests to localhost server are refused and blockedElectron/electron-packager 角度桌面应用程序 - 对 localhost 服务器的 http 请求被拒绝和阻止
【发布时间】:2020-04-22 15:03:08
【问题描述】:

我有基于 Angular 8 的电子桌面应用程序。我的 API 托管在 localhost 中。应用发送 HTTP 请求时,控制台报错:Failed to load resource and unsafe port. Error image

我禁用了 webSecurity,但它没有解决问题。这是电子的配置文件: electron config

有人对电子和对本地主机的请求有这样的问题吗?

【问题讨论】:

  • 很遗憾,我无法粘贴真实代码,目前我只有这些屏幕。

标签: angular deployment electron electron-packager


【解决方案1】:

主进程服务器监听3000端口,在渲染过程中我ajax请求本地主进程的服务器:

ajax.open('get', 'http://localhost:3000?name=' + "flag233");

在请求路径中添加“http://”!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-02
    • 2017-01-29
    • 2017-07-10
    • 2021-04-29
    • 2014-04-14
    • 1970-01-01
    • 2021-12-15
    • 2020-06-27
    相关资源
    最近更新 更多