Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3affa8908f |
@@ -1,7 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import InstanceSetupWizard from "@/modules/instance-setup/InstanceSetupWizard";
|
||||
import { useInstanceSetup } from "@/contexts/InstanceSetupProvider";
|
||||
import { useRouter } from "next/navigation";
|
||||
import FullScreenLoading from "@components/ui/FullScreenLoading";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function SetupPage() {
|
||||
return <InstanceSetupWizard />;
|
||||
const { setupRequired, loading } = useInstanceSetup();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading && !setupRequired) router.replace("/peers");
|
||||
}, [loading, setupRequired]);
|
||||
|
||||
return loading || !setupRequired ? (
|
||||
<FullScreenLoading />
|
||||
) : (
|
||||
<InstanceSetupWizard />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ export default function InstanceSetupProvider({
|
||||
const pathname = usePathname();
|
||||
|
||||
// Routes that don't need setup check
|
||||
const bypassRoutes = ["/setup", "/install"];
|
||||
const shouldBypass =
|
||||
bypassRoutes.includes(pathname) || isOIDCCallback();
|
||||
const bypassRoutes = ["/install"];
|
||||
const shouldBypass = bypassRoutes.includes(pathname) || isOIDCCallback();
|
||||
|
||||
// Skip setup check for NetBird hosted (cloud) deployments
|
||||
const isCloud = isNetBirdHosted();
|
||||
const isSetupPage = pathname === "/setup";
|
||||
|
||||
// Check instance status on mount
|
||||
useEffect(() => {
|
||||
@@ -70,10 +70,10 @@ export default function InstanceSetupProvider({
|
||||
|
||||
// Handle redirect separately to avoid setState during render conflicts
|
||||
useEffect(() => {
|
||||
if (setupRequired && !shouldBypass) {
|
||||
if (setupRequired && !shouldBypass && !isSetupPage) {
|
||||
router.replace("/setup");
|
||||
}
|
||||
}, [setupRequired, shouldBypass, router]);
|
||||
}, [setupRequired, shouldBypass, router, isSetupPage]);
|
||||
|
||||
// Show loading while checking (only for non-cloud, non-bypass routes)
|
||||
if (loading && !shouldBypass && !isCloud) {
|
||||
@@ -81,7 +81,7 @@ export default function InstanceSetupProvider({
|
||||
}
|
||||
|
||||
// If setup required and not on setup page, wait for redirect
|
||||
if (setupRequired && !shouldBypass) {
|
||||
if (setupRequired && !shouldBypass && !isSetupPage) {
|
||||
return <FullScreenLoading />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user