g1t/apps/web/app/routes/not-found.tsx
| 1 | import { data } from "react-router"; |
| 2 | |
| 3 | import type { Route } from "./+types/not-found"; |
| 4 | import { redirectIfRenamed } from "../lib/renamed.server"; |
| 5 | |
| 6 | /** |
| 7 | * Any address no other route matches. Throwing the 404 from a route, rather |
| 8 | * than leaving the router to, means the root loader still runs, so someone |
| 9 | * signed in sees the page in their own sidebar and not the public frame. |
| 10 | * |
| 11 | * An address under a renamed workspace's old name is sent to the new one |
| 12 | * first, so deep links keep working the same as its pages do. |
| 13 | */ |
| 14 | export async function loader({ request }: Route.LoaderArgs) { |
| 15 | const first = new URL(request.url).pathname.split("/")[1]; |
| 16 | if (first) await redirectIfRenamed(request, first); |
| 17 | throw data(null, { status: 404 }); |
| 18 | } |
| 19 | |
| 20 | export default function NotFound() { |
| 21 | return null; |
| 22 | } |