From df59442cd02354766c36316ce2e2b3abe125c587 Mon Sep 17 00:00:00 2001
From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
Date: Fri, 6 Mar 2026 22:57:38 -0600
Subject: [PATCH] always render ProtectedRoute (handling undefined roles
internally) and add Suspense fallback
---
web/src/App.tsx | 29 ++++++++--------------
web/src/components/auth/ProtectedRoute.tsx | 9 ++++++-
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 21babc2b9..01c415de4 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -11,7 +11,6 @@ import { Redirect } from "./components/navigation/Redirect";
import { cn } from "./lib/utils";
import { isPWA } from "./utils/isPWA";
import ProtectedRoute from "@/components/auth/ProtectedRoute";
-import { AuthProvider } from "@/context/auth-context";
import useSWR from "swr";
import { FrigateConfig } from "./types/frigateConfig";
import ActivityIndicator from "@/components/indicators/activity-indicator";
@@ -39,13 +38,11 @@ function App() {
return (
-
-
-
- {config?.safe_mode ? : }
-
-
-
+
+
+ {config?.safe_mode ? : }
+
+
);
}
@@ -85,17 +82,13 @@ function DefaultAppView() {
: "bottom-8 left-[52px]",
)}
>
-
+
+ }
+ >
-
- ) : (
-
- )
- }
- >
+ }>
} />
} />
} />
diff --git a/web/src/components/auth/ProtectedRoute.tsx b/web/src/components/auth/ProtectedRoute.tsx
index a7d1b3596..bcfa8fdf3 100644
--- a/web/src/components/auth/ProtectedRoute.tsx
+++ b/web/src/components/auth/ProtectedRoute.tsx
@@ -10,7 +10,7 @@ import {
export default function ProtectedRoute({
requiredRoles,
}: {
- requiredRoles: string[];
+ requiredRoles?: string[];
}) {
const { auth } = useContext(AuthContext);
@@ -36,6 +36,13 @@ export default function ProtectedRoute({
);
}
+ // Wait for config to provide required roles
+ if (!requiredRoles) {
+ return (
+
+ );
+ }
+
if (auth.isLoading) {
return (