Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(routing): show a Not Found page for unknown/uninstalled-extension routes

Juan Denisbd8842faf4df
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index c66a02de..064362a1 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -63,6 +63,7 @@ import Marketplace from './pages/Marketplace';
import Vaults from './pages/Vaults';
import Webhooks from './pages/Webhooks';
import StyleGuide from './pages/StyleGuide';
+import NotFound from './pages/NotFound';
import AppMap from './pages/AppMap';
import Documentation from './pages/Documentation';
import Deployments from './pages/Deployments';
@@ -449,6 +450,10 @@ function AppRoutes() {
<Route path="settings" element={<Settings />} />
<Route path="settings/:tab" element={<Settings />} />
{dashboardRoutes}
+ {/* Catch-all: an unknown URL, or an extension route whose
+ extension isn't installed (never registered above). Renders
+ inside the dashboard chrome instead of a blank page. */}
+ <Route path="*" element={<NotFound />} />
</Route>
</Routes>
);
diff --git a/frontend/src/pages/NotFound.jsx b/frontend/src/pages/NotFound.jsx
new file mode 100644
index 00000000..0416d113
--- /dev/null
+++ b/frontend/src/pages/NotFound.jsx
@@ -0,0 +1,57 @@
+import { useLocation, useNavigate } from 'react-router-dom';
+import { FileQuestion, LayoutDashboard, Blocks } from 'lucide-react';
+import { PageTopbar } from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import EmptyState from '@/components/EmptyState';
+import { useContributions } from '@/plugins/contributions';
+
+// Catch-all route (App.jsx `path="*"`). Reached for a genuinely unknown URL and,
+// importantly, for an extension route whose extension isn't installed/active
+// (that route is never registered, so React Router falls through to here instead
+// of rendering a blank page).
+//
+// Contributed routes load asynchronously from /api/v1/plugins/contributions, so
+// on a hard refresh straight onto an *installed* extension route this component
+// can mount for a beat before the route registers. We key off the contributions
+// `__ready` flag to show a loading skeleton until then, and only show the real
+// 404 once we know the route set is complete — no "Not found" flash.
+export default function NotFound() {
+ const location = useLocation();
+ const navigate = useNavigate();
+ const { __ready } = useContributions();
+
+ if (!__ready) {
+ return (
+ <div className="page-container">
+ <EmptyState loading title="Loading" />
+ </div>
+ );
+ }
+
+ return (
+ <div className="page-container">
+ <PageTopbar title="Page not found" />
+ <EmptyState
+ icon={FileQuestion}
+ title="Page not found"
+ description={
+ `We couldn't find ${location.pathname}. It may have moved, or it `
+ + `belongs to an extension that isn't installed. Check the `
+ + `Marketplace to install it.`
+ }
+ action={(
+ <div className="not-found__actions">
+ <Button onClick={() => navigate('/')}>
+ <LayoutDashboard size={16} />
+ Go to dashboard
+ </Button>
+ <Button variant="outline" onClick={() => navigate('/marketplace')}>
+ <Blocks size={16} />
+ Browse Marketplace
+ </Button>
+ </div>
+ )}
+ />
+ </div>
+ );
+}
diff --git a/frontend/src/plugins/contributions.js b/frontend/src/plugins/contributions.js
index 0200fc47..ea8d8ac7 100644
--- a/frontend/src/plugins/contributions.js
+++ b/frontend/src/plugins/contributions.js
@@ -205,6 +205,9 @@ export function refreshContributions() {
// built against an incompatible SDK before fetching it (plan 32 #1).
await loadRuntimeFrontends(
merged.frontends, merged.panel_sdk_version || merged.sdk_version);
+ // Mark the envelope as loaded so consumers (e.g. the NotFound page)
+ // can tell "contributions still loading" from "genuinely no route".
+ merged.__ready = true;
notify(merged);
return merged;
})
@@ -214,6 +217,7 @@ export function refreshContributions() {
// manifest baked into this frontend build instead of leaving
// contributed routes blank.
const fallback = normalizeContributions(getBuildTimeContributions());
+ fallback.__ready = true;
notify(fallback);
return fallback;
});
diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss
index 26771954..16d3ec87 100644
--- a/frontend/src/styles/main.scss
+++ b/frontend/src/styles/main.scss
@@ -86,6 +86,7 @@
// --------------------------------------------
@import 'pages/_auth';
@import 'pages/_dashboard';
+@import 'pages/_not-found';
@import 'pages/projects';
@import 'pages/fleet-proxy';
@import 'pages/_applications';
diff --git a/frontend/src/styles/pages/_not-found.scss b/frontend/src/styles/pages/_not-found.scss
new file mode 100644
index 00000000..d0f44727
--- /dev/null
+++ b/frontend/src/styles/pages/_not-found.scss
@@ -0,0 +1,8 @@
+// NotFound (catch-all) page — the EmptyState centers everything; we only need
+// the two action buttons to sit in a row with a gap and wrap on narrow screens.
+.not-found__actions {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--spacing-sm, 0.5rem);
+ justify-content: center;
+}