Set server port and host dynamically

This commit is contained in:
2025-05-28 17:23:52 +02:00
parent 3807645e6f
commit 9a0992f792

View File

@@ -5,6 +5,9 @@ const path = require('path');
const fs = require('fs');
// --- Server Setup ---
const PORT = process.env.PORT || 3000;
const HOST = '0.0.0.0';
const app = express();
const server = http.createServer(app);
const wss = new ws.Server({ server });
@@ -132,7 +135,6 @@ wss.on('connection', (socket) => {
pushSpiritToAllClients();
// --- Server Start ---
const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
console.log(`[Server] Läuft auf http://localhost:${PORT}`);
server.listen(PORT, HOST, () => {
console.log(`[Server] Läuft auf http://${HOST}:${PORT}`);
});