Store badges in Postgres, expose public/admin APIs, render an infinite footer slider, and ship /admin for paste-embed CRUD. Co-authored-by: Cursor <cursoragent@cursor.com>
16 lines
468 B
TypeScript
16 lines
468 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export function requireAdmin(req: NextRequest): NextResponse | null {
|
|
const adminKey = process.env.ADMIN_API_KEY;
|
|
if (!adminKey) {
|
|
return NextResponse.json({ error: "Admin API not configured" }, { status: 503 });
|
|
}
|
|
|
|
const auth = req.headers.get("authorization");
|
|
if (auth !== `Bearer ${adminKey}`) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
return null;
|
|
}
|