diff --git a/backend/src/server.ts b/backend/src/server.ts index fba40a6..e879772 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -13,7 +13,14 @@ const ENVIRONMENT = process.env.ENV || "dev"; const chess = new Chess(); -let httpServer = createServer(); +let expressApp = express(); +if (ENVIRONMENT === "dev") { + expressApp.use(morgan("dev")); + expressApp.use(cors()); +} + +let httpServer = createServer(expressApp); + const io = new Server(httpServer, { serveClient: false, cors: @@ -22,12 +29,6 @@ const io = new Server(httpServer, { : undefined, }); -let expressApp = express(); -if (ENVIRONMENT === "dev") { - expressApp.use(morgan("dev")); - expressApp.use(cors()); -} - // Add GET /health-check express route expressApp.get("/health-check", (req, res) => { res.status(200).send("OK"); diff --git a/frontend/src/utils/socket.tsx b/frontend/src/utils/socket.tsx index 8234596..452f515 100644 --- a/frontend/src/utils/socket.tsx +++ b/frontend/src/utils/socket.tsx @@ -2,7 +2,7 @@ import { io } from "socket.io-client"; const socket = window.location.hostname.includes("localhost") ? io("http://localhost:8000") - : io(window.location.hostname, { path: "api/" }); + : io(window.location.hostname, { path: "api/socket.io/" }); socket.on("connect", () => console.log("Connected to socket.io server"));