From 5b6b56eb865e12fc75633e3eeeb97d1ffde3bcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Z=C3=BCrcher?= Date: Thu, 8 May 2025 17:23:16 +0200 Subject: [PATCH] change local ip to dynamic of browser window --- src/boot/websocket.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/boot/websocket.ts b/src/boot/websocket.ts index 99b8e9d..b0b689f 100644 --- a/src/boot/websocket.ts +++ b/src/boot/websocket.ts @@ -4,8 +4,12 @@ import { initWebSocket } from 'src/services/websocket'; export default boot(({ app }) => { const $q = app.config.globalProperties.$q as QVueGlobals; + const host = window.location.hostname; // gets current domain or IP + const port = 8100; // your WebSocket port + + const randomId = Math.floor(Math.random() * 10001); // random number from 0 to 10000 + const ws = initWebSocket(`ws://${host}:${port}/ws?id=q${randomId}`, $q); - const ws = initWebSocket('ws://127.0.0.1:8100/ws?id=quasar', $q); app.config.globalProperties.$socket = ws; ws.connect(); });