diff options
Diffstat (limited to 'web/src/main.svelte')
| -rw-r--r-- | web/src/main.svelte | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/web/src/main.svelte b/web/src/main.svelte index 38b3699..baf02c9 100644 --- a/web/src/main.svelte +++ b/web/src/main.svelte @@ -17,7 +17,11 @@ let socket: WebSocket; onMount(function () { - socket = new WebSocket('ws://localhost:8080/ws'); + const proto = document.location.protocol === "https:" ? "wss:": "ws:"; + const port = document.location.port; + const host = document.location.hostname; + + socket = new WebSocket(`${proto}//${host}:${port}/ws`); // Expose websocket for debugging // ts-ignore window.WS = socket; |
