37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { LoaderFunctionArgs, useLoaderData } from "react-router";
|
|
import Page404 from "~/components/pages/Page404";
|
|
import ServerError from "~/components/ui/errors/ServerError";
|
|
import { getHostRoutingContextFromRequest } from "~/utils/app/HostRouting.server";
|
|
import { oauthAuthorizationServerMetadata } from "~/services/mcp/oauth.server";
|
|
|
|
type LoaderData = { surface: "admin" | "public" };
|
|
|
|
export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|
const url = new URL(request.url);
|
|
if (url.pathname === "/.well-known/oauth-authorization-server") {
|
|
return Response.json(oauthAuthorizationServerMetadata(), {
|
|
headers: {
|
|
"Cache-Control": "no-store",
|
|
},
|
|
});
|
|
}
|
|
// An unknown path on the admin host used to render the marketing 404, complete
|
|
// with "Anmelden"/"Registrieren"/AGB footer links, while an unknown path that
|
|
// *did* match an admin route rendered the operator 404. Same host, two very
|
|
// different pages (admin audit 2026-07-26, P0-12).
|
|
const surface: LoaderData["surface"] = getHostRoutingContextFromRequest(request) === "admin" ? "admin" : "public";
|
|
return Response.json({ surface } satisfies LoaderData, { status: 404 });
|
|
};
|
|
|
|
export default function () {
|
|
const { surface } = useLoaderData<LoaderData>();
|
|
if (surface === "admin") {
|
|
return <Page404 withLogo={false} withFooter={false} withGoBack={false} />;
|
|
}
|
|
return <Page404 />;
|
|
}
|
|
|
|
export function ErrorBoundary() {
|
|
return <ServerError />;
|
|
}
|