mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
ops: add public GET /api/health to logicsrc-web for status.profullstack.com (#233)
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
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 <noreply@anthropic.com>
This commit is contained in:
parent
c4c05331e3
commit
356a850cb2
2 changed files with 26 additions and 0 deletions
24
apps/logicsrc-web/src/app/api/health/route.ts
Normal file
24
apps/logicsrc-web/src/app/api/health/route.ts
Normal file
|
|
@ -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 });
|
||||
}
|
||||
|
|
@ -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<Response | NextResponse> {
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue