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; }