Compare commits

...

1 Commits

Author SHA1 Message Date
25c3c61c8c fix(api): Fixed websocket routing 2025-11-26 18:41:15 +01:00

View File

@@ -91,7 +91,12 @@ function setupSocketHandlers(socket) {
} }
// connect/disconnect helpers // connect/disconnect helpers
function connectWebSocket(url = "ws://localhost:9000/websocket") { function connectWebSocket(url = null) {
if (!url) {
const loc = window.location;
const protocol = loc.protocol === "https:" ? "wss:" : "ws:";
url = protocol + "//" + loc.host + "/websocket";
}
if (ws && ws.readyState === WebSocket.OPEN) return Promise.resolve(); if (ws && ws.readyState === WebSocket.OPEN) return Promise.resolve();
if (ws && ws.readyState === WebSocket.CONNECTING) { if (ws && ws.readyState === WebSocket.CONNECTING) {
// already connecting - return a promise that resolves on open // already connecting - return a promise that resolves on open