From ce8b0d9850ba4805c03948ff479bc55317555924 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Tue, 30 Jul 2024 12:36:31 +0200 Subject: [PATCH] FIX: remove '/' from host in client-control(#1156) --- .../common/components/client-modal/RedirectClientModal.tsx | 2 +- apps/client/src/common/hooks/useClientPath.ts | 4 +--- apps/client/src/common/utils/socket.ts | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/client/src/common/components/client-modal/RedirectClientModal.tsx b/apps/client/src/common/components/client-modal/RedirectClientModal.tsx index 163e481ba4..86df1c776a 100644 --- a/apps/client/src/common/components/client-modal/RedirectClientModal.tsx +++ b/apps/client/src/common/components/client-modal/RedirectClientModal.tsx @@ -38,7 +38,7 @@ export function RedirectClientModal(props: RedirectClientModalProps) { onClose(); }; - const host = `${window.location.origin}/`; + const host = window.location.origin; const canSubmit = path !== currentPath && path !== ''; return ( diff --git a/apps/client/src/common/hooks/useClientPath.ts b/apps/client/src/common/hooks/useClientPath.ts index d851dc5cbf..4c0d7b8664 100644 --- a/apps/client/src/common/hooks/useClientPath.ts +++ b/apps/client/src/common/hooks/useClientPath.ts @@ -12,9 +12,7 @@ export const useClientPath = () => { // notify of client path changes useEffect(() => { - //remove leading '/' from path - const fullPath = (pathname.startsWith('/') ? pathname.slice(1) : pathname) + search; - socketSendJson('set-client-path', fullPath); + socketSendJson('set-client-path', pathname + search); }, [pathname, search]); // navigate to new path when received from server diff --git a/apps/client/src/common/utils/socket.ts b/apps/client/src/common/utils/socket.ts index e05e2fc6a8..679b5d8d9e 100644 --- a/apps/client/src/common/utils/socket.ts +++ b/apps/client/src/common/utils/socket.ts @@ -36,7 +36,8 @@ export const connectSocket = () => { } socketSendJson('set-client-type', 'ontime'); - socketSendJson('set-client-path', location.pathname); + + socketSendJson('set-client-path', location.pathname + location.search); }; websocket.onclose = () => {