From 3f81a961ee5ed6ac61f7e8f4fc0ae8e7c5cbc58c Mon Sep 17 00:00:00 2001 From: haorwen Date: Sun, 21 Jun 2026 19:08:10 +0800 Subject: [PATCH] fix: skip tunnel redirect step when already on public domain to prevent auth loop --- .../onboarding/steps/get-public-domain.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/routes/onboarding/steps/get-public-domain.tsx b/src/routes/onboarding/steps/get-public-domain.tsx index 668b25f5..a7aefc45 100644 --- a/src/routes/onboarding/steps/get-public-domain.tsx +++ b/src/routes/onboarding/steps/get-public-domain.tsx @@ -7,6 +7,7 @@ import StyledButton from "@/components/styled/Button"; import { BASE_ORIGIN, tokenHeader } from "@/app/config"; import { getLocalAuthData, compareVersion } from "@/utils"; import { useAppSelector } from "@/app/store"; +import { useGetAutoTunnelInfoQuery } from "@/app/services/server"; const REQUIRED_VERSION = "0.5.19"; @@ -26,6 +27,22 @@ export default function GetPublicDomain() { const { t: tCommon } = useTranslation(); const { nextStep } = useWizard(); const currentVersion = useAppSelector((store) => store.server.version, shallowEqual); + const { data: autoInfo } = useGetAutoTunnelInfoQuery(); + + // If already on the tunnel domain, skip this step + useEffect(() => { + const tunnelUrl = autoInfo?.tunnel_status?.url; + if (tunnelUrl) { + try { + const tunnelOrigin = new URL(tunnelUrl).origin; + if (location.origin === tunnelOrigin) { + nextStep(); + } + } catch { + // ignore malformed URL + } + } + }, [autoInfo]); const [phase, setPhase] = useState("prompt"); const [logs, setLogs] = useState([]); @@ -55,7 +72,7 @@ export default function GetPublicDomain() { setCountdown(remaining); if (remaining <= 0) { clearInterval(countRef.current!); - nextStep(); + window.location.href = url; } }, 1000); }