diff --git a/webif/src/lib/index.ts b/webif/src/lib/index.ts deleted file mode 100644 index 856f2b6..0000000 --- a/webif/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/webif/src/lib/websocket.ts b/webif/src/lib/websocket.ts new file mode 100644 index 0000000..493a429 --- /dev/null +++ b/webif/src/lib/websocket.ts @@ -0,0 +1,9 @@ +export const determineWebSocketUrl = () => { + const urlParams = new URLSearchParams(window.location.search) + + // Use whatever is specified by the "ws" query parameter, default + // to the current host of nothing is specified. This allows us to + // manually define the WebSocket host when running the Svelte + // development server. + return urlParams.get('ws') || `ws://${window.location.host}` +} diff --git a/webif/src/routes/+page.svelte b/webif/src/routes/+page.svelte index e3fb110..08df097 100644 --- a/webif/src/routes/+page.svelte +++ b/webif/src/routes/+page.svelte @@ -1,5 +1,7 @@