From 660bc3455efb44642d0251c9e815cab71a8c5a96 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Sat, 5 Jul 2025 16:20:33 -0600 Subject: [PATCH] config: Update server URLs to use HTTPS for secure connections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change SERVER_URL from http:// to https:// in docker-compose - Add WebSocket URL conversion logic (https:// → wss://, http:// → ws://) - Resolves Mixed Content security error when client is served over HTTPS - Ensures secure communication between client and server --- client/src/services/gameClient.ts | 9 ++++++++- docker-compose.yml | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/services/gameClient.ts b/client/src/services/gameClient.ts index d259cb8..5d7fc4e 100644 --- a/client/src/services/gameClient.ts +++ b/client/src/services/gameClient.ts @@ -29,7 +29,14 @@ export class GameClient { // Fetch runtime configuration from our Express server const configResponse = await fetch('/api/config') const config = await configResponse.json() - const serverUrl = config.serverUrl || 'ws://localhost:2567' + let serverUrl = config.serverUrl || 'ws://localhost:2567' + + // Convert HTTP/HTTPS URLs to WebSocket URLs + if (serverUrl.startsWith('https://')) { + serverUrl = serverUrl.replace('https://', 'wss://') + } else if (serverUrl.startsWith('http://')) { + serverUrl = serverUrl.replace('http://', 'ws://') + } this.client = new Client(serverUrl) logger.info('Game client initialized with server:', serverUrl) diff --git a/docker-compose.yml b/docker-compose.yml index b28f4fc..4115fca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: environment: - NODE_ENV=production - PORT=3000 - - SERVER_URL=http://snatchGameServer.interno.com + - SERVER_URL=https://snatchGameServer.interno.com depends_on: - snatchgame-server networks: @@ -53,7 +53,7 @@ services: environment: - NODE_ENV=production - PORT=3001 - - SERVER_URL=http://snatchGameServer.interno.com + - SERVER_URL=https://snatchGameServer.interno.com depends_on: - snatchgame-server networks: