From 733d80812b2e3cc67b65f4b0cdb1cdb1ecb0bcb5 Mon Sep 17 00:00:00 2001 From: Neal Manaktola Date: Mon, 12 Sep 2022 10:32:30 -0400 Subject: [PATCH] add support for wrangler dev This example wasn't originally working with `wrangler dev`. An error code of 1015 was being returned when the websocket connection was being established. (TLS Error) This seems to fix it --- template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.js b/template.js index 9ed9b93..73ba5f8 100644 --- a/template.js +++ b/template.js @@ -57,7 +57,7 @@ const template = ` } const url = new URL(window.location) - url.protocol = "wss" + url.protocol = document.location.protocol === "http:" ? "ws://" : "wss://"; url.pathname = "/ws" websocket(url)