当 Apple 测试我的 macOS 应用程序时,他们没有获得打开本地 Webbserver 的权限

问题描述

我用 Electron 创建了一个 macOS 应用程序。 如果我构建并在本地运行该应用程序,则该应用程序运行没有任何问题。 但是当 Apple 尝试运行时,他们遇到了一个问题,导致出现此错误

[2021-06-09 10:59:19.217] [info]  ----------> start_server
[2021-06-09 10:59:19.218] [info]  3000
[2021-06-09 10:59:19.221] [info]  Error while starting server:  listen EPERM: operation not permitted 0.0.0.0:3000
[2021-06-09 10:59:19.222] [info]  Error caught:  listen EPERM: operation not permitted 0.0.0.0:3000
[2021-06-09 10:59:19.222] [info]  Error stack :  Error: listen EPERM: operation not permitted 0.0.0.0:3000

我正在尝试使用此代码启动 http 服务器:

module.exports = {
    startServer: async () => {
        _port = await UtilityService.getPort();
        console.log(_port);
        return new Promise((resolve,reject) => {
            httpServer.on('error',error => {
                console.log('Error while starting server: ',error.message);
                onError(error);
                reject(error);
            });
            httpServer.listen(_port,() => {
                console.log('HTTP Server listening on http://localhost:' + _port + '/');
                resolve();
            });
        })
    },

https://github.com/mattehalen/Scheduled-countdown/blob/master/src/server.js

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)