Skip to content

Commit

Permalink
Fix bugs in deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jloh02 committed Jan 20, 2024
1 parent 3ffbe3a commit 3de4f69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/socket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down

0 comments on commit 3de4f69

Please sign in to comment.