From ba989bd7f86f823e062cfce7437d89495ef527c6 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 2 Sep 2023 18:10:09 -0600 Subject: [PATCH] fix protocol in client JumpStom instance --- client/src/components/GameCanvas.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/GameCanvas.svelte b/client/src/components/GameCanvas.svelte index ea7dd15..a3f3dbc 100644 --- a/client/src/components/GameCanvas.svelte +++ b/client/src/components/GameCanvas.svelte @@ -19,8 +19,10 @@ const game = new Game(); const jumpStorm = new JumpStorm(game); - await jumpStorm.init(ctx, "http", "ws", document.location.host + "/api"); - jumpStorm.play(); + const { protocol, host } = document.location; + const isHttps = protocol.startsWith('https'); + jumpStorm.init(ctx, isHttps ? 'https' : 'http', isHttps ? 'wss' : 'ws', `${host}/api`) + .then(() => jumpStorm.play()); });