From bd8d04443350212b95451f800d75148712bb99f9 Mon Sep 17 00:00:00 2001 From: Lukas Bockstaller Date: Tue, 27 Feb 2024 00:09:24 +0100 Subject: [PATCH] feat(uimode) uses relative paths to establish websocket connection (#29617) --- packages/trace-viewer/src/ui/wsPort.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/trace-viewer/src/ui/wsPort.ts b/packages/trace-viewer/src/ui/wsPort.ts index fc08d4cdf4..298fa71d17 100644 --- a/packages/trace-viewer/src/ui/wsPort.ts +++ b/packages/trace-viewer/src/ui/wsPort.ts @@ -20,7 +20,9 @@ const callbacks = new Map void, reject: (arg: E export async function connect(options: { onEvent: (method: string, params?: any) => void, onClose: () => void }): Promise<(method: string, params?: any) => Promise> { const guid = new URLSearchParams(window.location.search).get('ws'); - const ws = new WebSocket(`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.hostname}:${window.location.port}/${guid}`); + const wsURL = new URL(`../${guid}`, window.location.toString()); + wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:'); + const ws = new WebSocket(wsURL); await new Promise(f => ws.addEventListener('open', f)); ws.addEventListener('close', options.onClose); ws.addEventListener('message', event => {