Conversation
…nd fix port mapping.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Implements infrastructure and client/server changes to support a gateway-driven, multi-server deployment where clients obtain an assigned game-server endpoint from the gateway and connect over TLS via an Nginx stream proxy + port-range mapping.
Changes:
- Game-server: initialize rooms defensively on create, add a
/statusendpoint, and add dynamic port-range selection + server-manager registration retry loop. - Gateway/client: switch room allocation/join flow to JSON responses (host/port/roomID) and update the client to connect to the assigned game-server endpoint.
- Ops: add host-level Nginx stream config + generator script, and update Kubernetes manifests for gateway exposure and game-server port range settings.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| server/server.ts | Adds room initialization, status endpoint behavior, port-range selection, and resilient registration with server-manager. |
| server/Dockerfile | Switches runtime base image to node:lts-slim. |
| server-manager/index.ts | Removes CORS middleware and binds to 0.0.0.0. |
| scripts/gen-stream-ports.sh | Generates Nginx stream port blocks for external→internal port mapping. |
| nginx-gameserver-stream.conf | Documents and configures host-level TLS termination + stream forwarding for game servers. |
| k8s.yaml | Updates gateway env/service exposure and configures game-server port-range env + ingress/cert-manager resources. |
| gateway/routes/createRoom.ts | Allocates room, fetches server assignment with retry, and returns JSON connection details. |
| gateway/routes/addToRoom.ts | Returns JSON connection details for joining an existing room. |
| gateway/index.ts | Updates CORS origin configuration and logs allowed origins. |
| client/styles.css | Updates landing/lobby styling and UI layout. |
| client/index.js | Updates gateway interaction and socket connection flow using JSON room assignment. |
| client/index.html | Updates lobby UI markup and sets production window.GATEWAY_URL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+132
to
134
| connectSocket(`${WS_SCHEME}://${hostIp}:${port}`, () => { | ||
| socket.emit("joinRoom", { name: pName, roomID }, (ack) => { | ||
| setLobbyLoading(false); |
Comment on lines
+6
to
+13
| const GATEWAY_URL = window.GATEWAY_URL; | ||
|
|
||
| // In production the game-server domain is server.boxgame.shadyggs.xyz. | ||
| // Nginx terminates TLS for wss://server.boxgame.shadyggs.xyz:<port> and | ||
| // forwards to the hostNetwork pod on the same port. | ||
| // In local dev the cookie will contain "localhost" so http:// is used. | ||
| const isLocalDev = GATEWAY_URL.startsWith("http://"); | ||
| const WS_SCHEME = isLocalDev ? "http" : "wss"; |
Comment on lines
45
to
+49
| const serverManager = process.env.SERVER_MANAGER_URL; | ||
|
|
||
| try { | ||
| // Get assigned a server | ||
| const response = await fetch(`${serverManager}/assign`); | ||
| const response = await fetchWithRetry(`${serverManager}/assign`); |
Comment on lines
+65
to
+68
| const INTERNAL_TO_EXTERNAL_OFFSET = 10000; | ||
| const internalPort = Number(response.headers.get("port")); | ||
| const externalPort = internalPort - INTERNAL_TO_EXTERNAL_OFFSET; | ||
|
|
Comment on lines
+5
to
+11
| // Cross-site cookie options required for Vercel (HTTPS) → VM (different origin). | ||
| // SameSite=None + Secure is mandatory for browsers to send cookies cross-site. | ||
| const COOKIE_OPTS = { | ||
| sameSite: "none" as const, | ||
| secure: true, | ||
| httpOnly: false, // client JS must read these values | ||
| }; |
Comment on lines
+4
to
+9
| // Cross-site cookie options – must match createRoom.ts | ||
| const COOKIE_OPTS = { | ||
| sameSite: "none" as const, | ||
| secure: true, | ||
| httpOnly: false, | ||
| }; |
Comment on lines
+12
to
+16
| const allowedOrigin = [ | ||
| "https://gateway.boxgame.shadyggs.xyz", | ||
| "http://localhost:4689", | ||
| "https://boxgame.shadyggs.xyz", | ||
| ]; |
Comment on lines
177
to
+179
| # Talk to server-manager inside the cluster | ||
| - name: SERVER_MANAGER_URL | ||
| value: "http://server-manager-svc.box-game.svc.cluster.local:4689" | ||
| value: "http://10.99.57.238:4689" |
Comment on lines
336
to
+337
| - name: SERVER_MANAGER_URL | ||
| value: "http://server-manager-svc.box-game.svc.cluster.local:4689" | ||
| # No fixed containerPort – the server calls listen(0) for a random port | ||
| value: "http://10.99.57.238:4689" |
Comment on lines
+104
to
105
| .nameBox:hover::before{ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1