无法从本地 IP 访问服务器



am使用冷冻机(https://git.freezer.life/exttex/freezerpc)并且我只能访问localhost://上的服务器。我尝试编辑settings.js,用0.0.0.0替换127.0.0.1,然后构建了它,但它仍然只在本地主机上运行。我试着禁用了防火墙,但没有。

class Settings {
constructor(electron = false) {
//Defaults
this.port = 10069;
this.serverIp = '0.0.0.0';
this.arl;
this.streamQuality = 3;
this.volume = 0.69;
this.electron = electron;
this.minimizeToTray = true;
this.closeOnExit = false;
this.width = 1280;
this.height = 720;

它有一个server.js文件,其中包含:

//Express
const app = express();
app.use(express.json({limit: '50mb'}));
app.use(express.static(path.join(__dirname, '../client', 'dist')));
app.use(cors({origin: 'http://localhost:8080'}));
//Server
const server = require('http').createServer(app);
const { Server } = require('socket.io');
const io = new Server(server, {
path: '/socket',
//CORS for webpack debug
cors: {
origin: 'http://localhost:8080',
methods: ["GET", "POST"],
}
});

这个在server.js文件的末尾

//Start server
let serverIp = override.host ? override.host : settings.serverIp;
let port = override.port ? override.port: settings.port;
server.listen(port, serverIp);
console.log(`Running on: http://${serverIp}:${port}`);
return settings;
}
module.exports = {createServer};

我是一个新手,我对is一无所知,因为我只是想运行访问

您从未真正启动过服务器。您需要呼叫app.listen

const PORT = 8080;
app.listen(PORT, () => {
console.log(`App is running on port ${PORT}!`);
});

相关内容

  • 没有找到相关文章

最新更新