feat: Updated status page title

This commit is contained in:
2026-08-25 14:11:21 +00:00
parent 7a0a1953f6
commit 270d55e6a6
+5 -20
View File
@@ -7,10 +7,7 @@ import type { StatusSnapshot } from "@/lib/api";
// auth redirect. This page is served to the public.
export const dynamic = "force-dynamic";
type FetchResult =
| { kind: "ok"; snapshot: StatusSnapshot }
| { kind: "not-found" }
| { kind: "unavailable" };
type FetchResult = { kind: "ok"; snapshot: StatusSnapshot } | { kind: "not-found" } | { kind: "unavailable" };
/*
* The control plane this call is made to is the visitor's own host.
@@ -27,7 +24,6 @@ function apiBase(proto: string, host: string): string {
}
async function fetchSnapshot(base: string, host: string, forwardedFor: string, pageId: string): Promise<FetchResult> {
// The instance is resolved server-side from the visitor's host, so it has
// to be forwarded explicitly — this is a server-to-server call and its own
// Host names the Go service.
@@ -93,34 +89,23 @@ function unavailableSnapshot(): StatusSnapshot {
};
}
export default async function PublicStatusPage({
params,
}: {
params: Promise<{ pageId: string }>;
}) {
export default async function PublicStatusPage({ params }: { params: Promise<{ pageId: string }> }) {
const { pageId } = await params;
const h = await headers();
const host = h.get("x-forwarded-host") ?? h.get("host") ?? "";
const inboundFor = h.get("x-forwarded-for");
const peer = h.get("x-real-ip");
const forwardedFor = [inboundFor, inboundFor ? null : peer]
.filter((v): v is string => !!v)
.join(", ");
const forwardedFor = [inboundFor, inboundFor ? null : peer].filter((v): v is string => !!v).join(", ");
const proto = h.get("x-forwarded-proto")?.split(",")[0].trim() || "https";
const result = await fetchSnapshot(apiBase(proto, host), host, forwardedFor, pageId);
if (result.kind === "not-found") notFound();
return (
<StatusPageView
pageId={pageId}
initial={result.kind === "ok" ? result.snapshot : unavailableSnapshot()}
/>
);
return <StatusPageView pageId={pageId} initial={result.kind === "ok" ? result.snapshot : unavailableSnapshot()} />;
}
export async function generateMetadata({ params }: { params: Promise<{ pageId: string }> }) {
const { pageId } = await params;
return { title: `Status ${pageId}` };
return { title: `Status: ${pageId}` };
}