use one server for both http and ws

This commit is contained in:
Alexander Bentkamp
2022-10-18 17:09:53 +02:00
parent 4e6c96e6f3
commit 039464924d
5 changed files with 15 additions and 389 deletions
+2 -4
View File
@@ -2,14 +2,12 @@ const WebSocket = require("ws");
const express = require("express");
const app = express()
const path = require("path")
const fs = require("fs");
const { spawn } = require('child_process');
const PORT = 8765;
const PORT = process.env.PORT || 8080;
const server = app
.use(express.static('./build'))
.use(express.static(path.join(__dirname, '../client/dist/')))
.listen(PORT, () => console.log(`Listening on ${PORT}`));
const wss = new WebSocket.Server({ server })