From 896662b2adceca8cc2ef3113cadb83a61c94ba13 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Wed, 12 Jun 2024 17:03:42 +0100 Subject: :rocket: Build server component runtime. --- priv/static/lustre-server-component.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'priv/static/lustre-server-component.mjs') diff --git a/priv/static/lustre-server-component.mjs b/priv/static/lustre-server-component.mjs index 2f2e868..8913469 100644 --- a/priv/static/lustre-server-component.mjs +++ b/priv/static/lustre-server-component.mjs @@ -388,8 +388,11 @@ var LustreServerComponent = class extends HTMLElement { } else if (prev !== next) { const id = this.getAttribute("id"); const route = next + (id ? `?id=${id}` : ""); + const protocol = window.location.protocol === "https:" ? "wss" : "ws"; this.#socket?.close(); - this.#socket = new WebSocket(`ws://${window.location.host}${route}`); + this.#socket = new WebSocket( + `${protocol}://${window.location.host}${route}` + ); this.#socket.addEventListener( "message", (message) => this.messageReceivedCallback(message) -- cgit v1.2.3