From fb7cb35921b73fd22a4ef045fe23b8dab87a7af4 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 26 Jan 2025 22:54:29 +0100 Subject: [PATCH] Update. --- src/snek/static/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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