From a3cce59a2ae40afe45de7e3662d81debd09553e5 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Wed, 23 Aug 2023 12:27:34 -0500 Subject: [PATCH] fix https connection --- frontend/composables/use-server-events.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/composables/use-server-events.ts b/frontend/composables/use-server-events.ts index 2d4eaa0..53f0631 100644 --- a/frontend/composables/use-server-events.ts +++ b/frontend/composables/use-server-events.ts @@ -13,7 +13,12 @@ let socket: WebSocket | null = null; const listeners = new Map void)[]>(); function connect(onmessage: (m: EventMessage) => void) { - const ws = new WebSocket(`ws://${window.location.host}/api/v1/ws/events`); + let protocol = "ws"; + if (window.location.protocol === "https:") { + protocol = "wss"; + } + + const ws = new WebSocket(`${protocol}://${window.location.host}/api/v1/ws/events`); ws.onopen = () => { console.debug("connected to server");