Spaces:
Running

michdubai commited on
Commit
4876c3f
·
verified ·
1 Parent(s): 07e9c53

Update frontend/js/websocket-client.js

Browse files
Files changed (1) hide show
  1. frontend/js/websocket-client.js +3 -2
frontend/js/websocket-client.js CHANGED
@@ -27,8 +27,9 @@ export class WebSocketClient {
27
  // Store callbacks
28
  this.callbacks = callbacks;
29
 
30
- // Create WebSocket connection
31
- this.websocket = new WebSocket(`ws://localhost:8000/ws/${this.clientId}`);
 
32
 
33
  this.websocket.onopen = () => {
34
  console.log("WebSocket connection established");
 
27
  // Store callbacks
28
  this.callbacks = callbacks;
29
 
30
+ // Create dynamic, secure WebSocket connection relative to the current window address
31
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
32
+ this.websocket = new WebSocket(`${protocol}//${window.location.host}/ws/${this.clientId}`);
33
 
34
  this.websocket.onopen = () => {
35
  console.log("WebSocket connection established");