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");