首页 > 解决方案 > 当 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

标签: electronapp-storeappstore-approvalhttpserverappstore-sandbox

解决方案


推荐阅读