Use secure WebSocket protocol based on location
This commit is contained in:
@@ -246,7 +246,8 @@ class SpinnerController {
|
|||||||
|
|
||||||
connectWebSocket() {
|
connectWebSocket() {
|
||||||
if (this.ws) this.ws.close();
|
if (this.ws) this.ws.close();
|
||||||
this.ws = new WebSocket(`ws://${location.host}`);
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
|
this.ws = new WebSocket(`${wsProtocol}://${location.host}`);
|
||||||
this.ws.addEventListener('open', () => {
|
this.ws.addEventListener('open', () => {
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
console.log("WebSocket connected!");
|
console.log("WebSocket connected!");
|
||||||
|
|||||||
Reference in New Issue
Block a user