fix: defer setup wizard HTTP detection to avoid hydration mismatch

This commit is contained in:
Linus Rath
2026-05-20 19:05:11 +02:00
parent 1c44f59ba1
commit 5023d31202
+7 -3
View File
@@ -101,10 +101,14 @@ export default function SetupWizardPage() {
const [config, setConfig] = useState<WizardConfig>(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<boolean>(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(() => {