From 8e6d2cea390de559d76f0df758f6591dde8b7823 Mon Sep 17 00:00:00 2001 From: DCCONSTRUCTIONS Date: Mon, 4 May 2026 22:07:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=A3=D0=9D=D0=9A=D0=A6=D0=98=D0=98=20-?= =?UTF-8?q?=20NODEDC=20LAUNCHER:=20preserve=20auth=20returnTo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/LauncherApp.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/LauncherApp.tsx b/src/app/LauncherApp.tsx index 032786e..680e963 100644 --- a/src/app/LauncherApp.tsx +++ b/src/app/LauncherApp.tsx @@ -187,7 +187,7 @@ export function LauncherApp() { useEffect(() => { if (!authSession || authSession.authenticated) return; - window.location.replace(authSession.loginUrl || "/auth/login"); + window.location.replace(buildLoginRedirectUrl(authSession.loginUrl)); }, [authSession]); useEffect(() => { @@ -658,3 +658,17 @@ function AuthStateScreen({ ); } + +function buildLoginRedirectUrl(loginUrl?: string) { + const url = new URL(loginUrl || "/auth/login", window.location.origin); + + if (!url.searchParams.has("returnTo")) { + const returnTo = `${window.location.pathname}${window.location.search}${window.location.hash}`; + + if (returnTo && returnTo !== "/") { + url.searchParams.set("returnTo", returnTo); + } + } + + return url.origin === window.location.origin ? `${url.pathname}${url.search}${url.hash}` : url.toString(); +}