From 59f60328e2730f3405a155fcb302f3a30fb22d36 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Fri, 15 Aug 2025 13:41:12 -0600 Subject: [PATCH] Configurar URLs para usar rutas de nginx sin puertos --- client/.env.production | 2 ++ client/src/services/colyseus.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 client/.env.production diff --git a/client/.env.production b/client/.env.production new file mode 100644 index 0000000..43310e3 --- /dev/null +++ b/client/.env.production @@ -0,0 +1,2 @@ +VITE_WS_URL=wss://snatchgame.nucleoriofrio.com/ws +VITE_API_URL=https://snatchgame.nucleoriofrio.com/api \ No newline at end of file diff --git a/client/src/services/colyseus.ts b/client/src/services/colyseus.ts index 5ec9edd..f43909c 100644 --- a/client/src/services/colyseus.ts +++ b/client/src/services/colyseus.ts @@ -37,13 +37,14 @@ class ColyseusService { constructor() { const defaultHost = typeof window !== "undefined" ? window.location.hostname : "localhost"; const defaultProtocol = typeof window !== "undefined" && window.location.protocol === "https:" ? "wss" : "ws"; - const defaultPort = 3000; - const fallbackUrl = `${defaultProtocol}://${defaultHost}:${defaultPort}`; + const httpProtocol = typeof window !== "undefined" && window.location.protocol === "https:" ? "https" : "http"; + + // Para producción, usar las rutas de nginx sin puerto + const fallbackUrl = `${defaultProtocol}://${defaultHost}/ws`; + const apiFallback = `${httpProtocol}://${defaultHost}/api`; + const url = import.meta.env.VITE_WS_URL || fallbackUrl; this.client = new Client(url); - - const httpProtocol = typeof window !== "undefined" && window.location.protocol === "https:" ? "https" : "http"; - const apiFallback = `${httpProtocol}://${defaultHost}:${defaultPort}/api`; this.apiBase = (import.meta.env as any).VITE_API_URL || apiFallback; }