From 2b2e72e735135d0b6e3bfd4ab5b7aab862bf6948 Mon Sep 17 00:00:00 2001 From: Paul Frank Date: Tue, 20 Jun 2023 19:55:11 +0000 Subject: [PATCH] fix websocket path --- src/api/devices.api.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/devices.api.ts b/src/api/devices.api.ts index 541b694..cebcd6c 100644 --- a/src/api/devices.api.ts +++ b/src/api/devices.api.ts @@ -42,9 +42,9 @@ export default class DevicesAPIService { if (this.socket) throw "already initialized"; if (baseUrl.endsWith("/")) baseUrl = baseUrl.slice(0, -1); this.baseUrl = baseUrl; - const pathname = new URL(baseUrl).pathname; - - const sio_path = pathname + "ws/socket.io/" + let pathname = new URL(baseUrl).pathname; + if (pathname.endsWith("/")) pathname = pathname.slice(0, -1); + const sio_path = pathname + "/ws/socket.io/" // const wsUrl = baseUrl.replace("http", "ws"); console.log(`Connecting to Energy Assistant WS API path ${sio_path}`);