From 356a850cb20c75248bb8dccf130a2a281b3cc4d0 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Tue, 6 Oct 2026 11:46:50 -0700 Subject: [PATCH] ops: add public GET /api/health to logicsrc-web for status.profullstack.com (#233) A filesystem route, so it wins over the CommandBoard /api/:path* rewrite (unset in prod today, which left /api/health to the catch-all 404). One head-only PostgREST query on blog_posts with a 3s cap: 200 {"status":"ok","db":"ok"} or 503 {"status":"error","db":"down"}, Cache-Control: no-store. The proxy skips the crawl gateway for the path. Co-authored-by: Claude Opus 5.5 --- apps/logicsrc-web/src/app/api/health/route.ts | 24 +++++++++++++++++++ apps/logicsrc-web/src/proxy.ts | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 apps/logicsrc-web/src/app/api/health/route.ts 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.