fix health check endpoint
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
- [ ] Add rate limiting (10 requests/minute per user)
|
||||
- [ ] Add Zod validation for messages
|
||||
- [ ] Add message length limits
|
||||
- [ ] Modify `src/app/api/diagnostics/route.ts` - Restrict to authenticated admins
|
||||
- [x] Modify `src/app/api/diagnostics/route.ts` - Keep public (used by homepage setup checklist before login)
|
||||
|
||||
### SEO
|
||||
- [ ] Modify `src/app/layout.tsx` - Add Open Graph metadata
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { headers } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/lib/auth";
|
||||
|
||||
type StatusLevel = "ok" | "warn" | "error";
|
||||
|
||||
@@ -33,15 +31,10 @@ interface DiagnosticsResponse {
|
||||
overallStatus: StatusLevel;
|
||||
}
|
||||
|
||||
// This endpoint is intentionally public (no auth required) because it's used
|
||||
// by the setup checklist on the homepage before users are logged in.
|
||||
// It only returns boolean flags about configuration status, not sensitive data.
|
||||
export async function GET(req: Request) {
|
||||
// Require authentication for diagnostics endpoint
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) {
|
||||
return NextResponse.json(
|
||||
{ error: "Unauthorized. Please sign in to access diagnostics." },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
const env = {
|
||||
POSTGRES_URL: Boolean(process.env.POSTGRES_URL),
|
||||
BETTER_AUTH_SECRET: Boolean(process.env.BETTER_AUTH_SECRET),
|
||||
|
||||
Reference in New Issue
Block a user