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()); });