Skip to content

Commit 60d0aa6

Browse files
authored
fix: handle 404 on unknown top level routes (#10964)
1 parent 2aa7936 commit 60d0aa6

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

site/src/AppRouter.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,26 +320,29 @@ export const AppRouter: FC = () => {
320320
</Route>
321321
</Route>
322322

323-
<Route path="/:username">
324-
<Route path=":workspace">
325-
<Route index element={<WorkspacePage />} />
326-
<Route
327-
path="builds/:buildNumber"
328-
element={<WorkspaceBuildPage />}
329-
/>
330-
<Route path="settings" element={<WorkspaceSettingsLayout />}>
331-
<Route index element={<WorkspaceSettingsPage />} />
332-
<Route
333-
path="parameters"
334-
element={<WorkspaceParametersPage />}
335-
/>
336-
<Route
337-
path="schedule"
338-
element={<WorkspaceSchedulePage />}
339-
/>
340-
</Route>
341-
</Route>
323+
{/* In order for the 404 page to work properly the routes that start with
324+
top level parameter must be fully qualified. */}
325+
<Route path="/:username/:workspace" element={<WorkspacePage />} />
326+
<Route
327+
path="/:username/:workspace/builds/:buildNumber"
328+
element={<WorkspaceBuildPage />}
329+
/>
330+
<Route
331+
path="/:username/:workspace/settings"
332+
element={<WorkspaceSettingsLayout />}
333+
>
334+
<Route index element={<WorkspaceSettingsPage />} />
335+
<Route
336+
path="parameters"
337+
element={<WorkspaceParametersPage />}
338+
/>
339+
<Route path="schedule" element={<WorkspaceSchedulePage />} />
342340
</Route>
341+
342+
{/* Using path="*"" means "match anything", so this route
343+
acts like a catch-all for URLs that we don't have explicit
344+
routes for. */}
345+
<Route path="*" element={<NotFoundPage />} />
343346
</Route>
344347

345348
{/* Pages that don't have the dashboard layout */}
@@ -354,11 +357,6 @@ export const AppRouter: FC = () => {
354357
element={<TemplateVersionEditorPage />}
355358
/>
356359
</Route>
357-
358-
{/* Using path="*"" means "match anything", so this route
359-
acts like a catch-all for URLs that we don't have explicit
360-
routes for. */}
361-
<Route path="*" element={<NotFoundPage />} />
362360
</Routes>
363361
</Router>
364362
</Suspense>

0 commit comments

Comments
 (0)