From b248963e7159ed22fdd0383e89a9b82656e8ecfd Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Sat, 14 Feb 2026 00:36:13 +0000 Subject: [PATCH] feat: auto-detect WSS gateway URL for HTTPS deployments --- src/components/LoginScreen.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/LoginScreen.tsx b/src/components/LoginScreen.tsx index 0119731..24eca4e 100644 --- a/src/components/LoginScreen.tsx +++ b/src/components/LoginScreen.tsx @@ -12,7 +12,18 @@ interface Props { function getInitialUrl(): string { const stored = getStoredCredentials(); if (stored) return stored.url; - return import.meta.env.VITE_GATEWAY_WS_URL || `ws://${window.location.hostname}:18789`; + if (import.meta.env.VITE_GATEWAY_WS_URL) return import.meta.env.VITE_GATEWAY_WS_URL; + const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'; + const host = window.location.hostname; + // When served over HTTPS, assume gateway is on a sibling subdomain (e.g. marlbot-gw.example.com) + if (protocol === 'wss') { + const parts = host.split('.'); + if (parts.length >= 2) { + parts[0] = parts[0] + '-gw'; + return `${protocol}://${parts.join('.')}`; + } + } + return `${protocol}://${host}:18789`; } function getInitialToken(): string {