From 5023d312020501c902ad3aaf22fc27d61fb9ee66 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 20 May 2026 19:05:11 +0200 Subject: [PATCH] fix: defer setup wizard HTTP detection to avoid hydration mismatch --- app/setup/page.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/setup/page.tsx b/app/setup/page.tsx index 09859fd3..761cdf54 100644 --- a/app/setup/page.tsx +++ b/app/setup/page.tsx @@ -101,10 +101,14 @@ export default function SetupWizardPage() { const [config, setConfig] = useState(EMPTY_CONFIG); const [stepIndex, setStepIndex] = useState(0); const [completed, setCompleted] = useState(false); - // Detect synchronously on first client render so the cleartext-credentials - // warning is in the first paint instead of popping in after hydration. - const [insecureContext] = useState(detectInsecureContext); + // Resolved in a post-mount effect, not at render, so the server-rendered + // HTML (where window is absent) matches the client's first paint and + // doesn't trip a hydration mismatch. + const [insecureContext, setInsecureContext] = useState(false); const [insecureAcknowledged, setInsecureAcknowledged] = useState(false); + useEffect(() => { + setInsecureContext(detectInsecureContext()); + }, []); // ─── Initial status load ──────────────────────────────────────────────── useEffect(() => {