diff --git a/pkg/web/src/routes/+page.svelte b/pkg/web/src/routes/+page.svelte index 6b5b7e12..34dc4c93 100644 --- a/pkg/web/src/routes/+page.svelte +++ b/pkg/web/src/routes/+page.svelte @@ -46,12 +46,12 @@ const json = await res.json(); quote = json.quotes[Math.floor(Math.random() * json.quotes.length)]; - let wsUrl = `${PUBLIC_BACKEND_WS_ENDPOINT}`; - if (wsUrl === "") { - // Unlike with fetch, which understands "/" as "the current page", for WS we need to build the URI by hand. - const l = window.location; - wsUrl = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + (((l.port != 80) && (l.port != 443)) ? ":" + l.port : "") + "/ws"; - } + let wsUrl = `${PUBLIC_BACKEND_WS_ENDPOINT}`; + if (wsUrl === "") { + // Unlike with fetch, which understands "/" as "the current page", for WS we need to build the URI by hand. + const l = window.location; + wsUrl = ((l.protocol === "https:") ? "wss://" : "ws://") + l.hostname + (((l.port != 80) && (l.port != 443)) ? ":" + l.port : "") + "/ws"; + } socket = new WebSocket(wsUrl); socket.addEventListener('message', function (event) { const data = JSON.parse(event.data);