fix protocol in client JumpStom instance

This commit is contained in:
Elizabeth Hunt 2023-09-02 18:10:09 -06:00
parent c9070bb056
commit ba989bd7f8
Signed by: simponic
GPG Key ID: 52B3774857EB24B1

View File

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