diff options
| author | myOmikron <git@omikron.dev> | 2023-01-25 21:47:51 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-02-24 12:47:40 +0100 |
| commit | c3c450eeb037adab5873cbd63ed772c4b7121a63 (patch) | |
| tree | 89d5b94a9725646c4c669fc58f2ac7ef8079302b /web/src/main.svelte | |
| parent | 500475141ce02f85812bfacbc3528606eab9a5e0 (diff) | |
| download | WRMS-c3c450eeb037adab5873cbd63ed772c4b7121a63.tar.gz WRMS-c3c450eeb037adab5873cbd63ed772c4b7121a63.zip | |
Fixed websocket location
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; |
