diff --git a/src/snek/static/app.js b/src/snek/static/app.js index 2be1c09..f6490e8 100644 --- a/src/snek/static/app.js +++ b/src/snek/static/app.js @@ -208,9 +208,11 @@ class Socket extends EventHandler { ws = null isConnected = null isConnecting = null + url = null connectPromises = [] constructor() { super() + this.url = window.location.hostname == 'localhost' ? 'ws://localhost/rpc.ws' : 'wss://' + window.location.hostname +'/rpc.ws' this.ensureConnection() } _camelToSnake(str) { @@ -254,7 +256,8 @@ class Socket extends EventHandler { } return new Promise((resolve,reject)=>{ me.connectPromises.push(resolve) - const ws = new WebSocket("ws://localhost:8081/rpc.ws") + + const ws = new WebSocket(this.url) ws.onopen = (event) => { me.ws = ws me.isConnected = true