diff --git a/docker-compose.yml b/docker-compose.yml index e3f8865..a9cfdb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: networks: - webapp ports: - - 1337:80 + - 28303:80 restart: always container_name: jumpstorm-client hostname: client diff --git a/server/src/constants.ts b/server/src/constants.ts index 2968d3a..11b8c75 100644 --- a/server/src/constants.ts +++ b/server/src/constants.ts @@ -1,4 +1,5 @@ export namespace Constants { + export const HOST = '0.0.0.0'; export const SERVER_PORT = 8080; export const SERVER_TICK_RATE = (1 / 120) * 1000; export const GAME_TOPIC = 'game'; diff --git a/server/src/server.ts b/server/src/server.ts index 3beebd5..f28c80f 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -38,6 +38,7 @@ export class GameServer { public serve() { if (!this.server) this.server = Bun.serve({ + host: Constants.HOST, port: Constants.SERVER_PORT, fetch: (req, srv) => this.fetchHandler(req, srv), websocket: { @@ -137,7 +138,7 @@ export class GameServer { const headers = new Headers(); headers.set('Access-Control-Allow-Origin', '*'); - if (url.pathname == '/assign') { + if (url.pathname === '/api/assign') { if (this.sessionManager.numSessions() > Constants.MAX_PLAYERS) return new Response('too many players', { headers, status: 400 }); @@ -154,7 +155,7 @@ export class GameServer { const sessionId = cookie.split(';').at(0)!.split('SessionId=').at(1); - if (url.pathname == '/game') { + if (url.pathname === '/api/game') { server.upgrade(req, { headers, data: { @@ -165,7 +166,7 @@ export class GameServer { return new Response('upgraded to ws', { headers }); } - if (url.pathname == '/me') { + if (url.pathname === '/api/me') { return new Response(sessionId, { headers }); }