Add debug endpoint

This commit is contained in:
Manohar Gupta 2026-05-17 00:46:12 +05:30
parent cb7d9411ff
commit 082c2bcdd8
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,26 @@
import { NextResponse } from "next/server";
import { sql } from "@/db";
import { cookies } from "next/headers";
export async function GET() {
const sessionToken = (await cookies()).get("tia_session")?.value;
if (!sessionToken) {
return NextResponse.json({ error: "no cookie" });
}
// Debug: show what's in sessions and family_members
const sessions = await sql.unsafe(
`SELECT s.user_id, s.session_token, fm.family_id as fm_family, fm.user_id as fm_user
FROM sessions s
LEFT JOIN family_members fm ON fm.user_id::text = s.user_id::text
WHERE s.session_token = $1`,
[sessionToken]
);
return NextResponse.json({
cookie: sessionToken?.slice(0, 20) + "...",
sessionsFound: sessions?.length,
sessions
});
}

View file

@ -10,6 +10,7 @@ const publicRoutes = [
"/api/admin/auth", "/api/admin/auth",
"/api/onboarding", "/api/onboarding",
"/api/ai", "/api/ai",
"/api/auth/debug",
]; ];
// Protected API routes that need authentication // Protected API routes that need authentication