From efbcd10fb04847b4ec216932c69d4b2b97b00eac Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 26 Dec 2023 14:28:04 +0100 Subject: [PATCH] fix: websocket url --- frontend/static/js/api/chat/channel.js | 7 +------ frontend/static/js/api/matchmaking.js | 7 +------ frontend/static/js/api/tournament/tournament.js | 10 ++++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/frontend/static/js/api/chat/channel.js b/frontend/static/js/api/chat/channel.js index 066c6ff..22843b5 100644 --- a/frontend/static/js/api/chat/channel.js +++ b/frontend/static/js/api/chat/channel.js @@ -14,12 +14,7 @@ class Channel { // reload = function to use when we receive a message async connect(reload) { - let url = ` - ${window.location.protocol == 'https' ? 'wss' : 'ws'} - ://${window.location.host} - /ws/chat/ - ${this.channel_id}/ - `; + let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/chat/${this.channel_id}`; this.chatSocket = new WebSocket(url); this.chatSocket.onmessage = (event) =>{ diff --git a/frontend/static/js/api/matchmaking.js b/frontend/static/js/api/matchmaking.js index 0bd27ed..e55e48c 100644 --- a/frontend/static/js/api/matchmaking.js +++ b/frontend/static/js/api/matchmaking.js @@ -19,12 +19,7 @@ class MatchMaking if (!await this.client.isAuthentificate()) return null; - let url = ` - ${window.location.protocol == 'https' ? 'wss' : 'ws'} - ://${window.location.host} - /ws/matchmaking/ - ${mode} - `; + let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/matchmaking/${mode}`; this._socket = new WebSocket(url); diff --git a/frontend/static/js/api/tournament/tournament.js b/frontend/static/js/api/tournament/tournament.js index 2c953db..63afdaa 100644 --- a/frontend/static/js/api/tournament/tournament.js +++ b/frontend/static/js/api/tournament/tournament.js @@ -77,13 +77,11 @@ class Tourmanent if (!await this.client.isAuthentificate()) return null; - let url = ` - ${window.location.protocol == 'https' ? 'wss' : 'ws'} - ://${window.location.host} - /ws/tournaments/ - ${this.id} - `; + console.log(window.location.protocol); + let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/tournaments/${this.id}`; + console.log(url); + this._socket = new WebSocket(url); this.connected = true;