Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions sites/sh1pt.com/app/api/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Public health check for status.profullstack.com: one HEAD select against
// profiles, capped at 3s. Never returns error details.

import { NextResponse } from 'next/server';
import { getSupabaseServiceClient } from '@/lib/supabase/service';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

const HEADERS = { 'Cache-Control': 'no-store' };

export async function GET() {
try {
const { error } = await getSupabaseServiceClient()
.from('profiles')
.select('id', { head: true })
.limit(1)
.abortSignal(AbortSignal.timeout(3000));
if (error) throw error;
return NextResponse.json({ status: 'ok', db: 'ok' }, { headers: HEADERS });
} catch {
return NextResponse.json(
{ status: 'error', db: 'down' },
{ status: 503, headers: HEADERS },
);
}
}
3 changes: 3 additions & 0 deletions sites/sh1pt.com/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { gate } from "@/lib/crawl-gateway";
import { NextResponse, type NextRequest } from 'next/server';

export async function middleware(request: NextRequest) {
// The status page's health check is never gated or redirected.
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.
Expand Down
Loading