diff --git a/apps/logicsrc-web/src/app/api/health/route.ts b/apps/logicsrc-web/src/app/api/health/route.ts new file mode 100644 index 00000000..521fda98 --- /dev/null +++ b/apps/logicsrc-web/src/app/api/health/route.ts @@ -0,0 +1,24 @@ +import { NextResponse } from "next/server"; +import { publicClient } from "@/lib/supabase"; + +// A cached answer reports the cache's health, not the app's. +export const dynamic = "force-dynamic"; + +const headers = { "Cache-Control": "no-store" }; + +// GET /api/health — public liveness + database check for status.profullstack.com. +// A filesystem route, so it wins over the CommandBoard `/api/:path*` rewrite. +// One head-only PostgREST query with a 3s cap; the failure reason is never returned. +export async function GET() { + try { + const { error } = await publicClient() + .from("blog_posts") + .select("slug", { head: true }) + .limit(1) + .abortSignal(AbortSignal.timeout(3000)); + if (error) throw error; + } catch { + return NextResponse.json({ status: "error", db: "down" }, { status: 503, headers }); + } + return NextResponse.json({ status: "ok", db: "ok" }, { headers }); +} diff --git a/apps/logicsrc-web/src/proxy.ts b/apps/logicsrc-web/src/proxy.ts index a7eeb019..a09acc2e 100644 --- a/apps/logicsrc-web/src/proxy.ts +++ b/apps/logicsrc-web/src/proxy.ts @@ -8,6 +8,8 @@ import type { NextRequest } from "next/server"; const ALLOWED_APEX = process.env.PUBLIC_DOMAIN || "logicsrc.com"; export async function proxy(request: NextRequest): Promise { + // The status page's health probe skips the crawl gateway and host redirect. + if (request.nextUrl.pathname === "/api/health") return NextResponse.next(); // Crawl gateway first: AI training crawlers get 402 Payment Required (or the // sales page at /crawl) unless they present a paid pass. People, Googlebot // and retrieval crawlers fall through to everything below.