feat: auto-detect WSS gateway URL for HTTPS deployments
This commit is contained in:
@@ -12,7 +12,18 @@ interface Props {
|
|||||||
function getInitialUrl(): string {
|
function getInitialUrl(): string {
|
||||||
const stored = getStoredCredentials();
|
const stored = getStoredCredentials();
|
||||||
if (stored) return stored.url;
|
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 {
|
function getInitialToken(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user