Add debug endpoint
This commit is contained in:
parent
cb7d9411ff
commit
082c2bcdd8
2 changed files with 27 additions and 0 deletions
26
src/app/api/auth/debug/route.ts
Normal file
26
src/app/api/auth/debug/route.ts
Normal 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
|
||||
});
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ const publicRoutes = [
|
|||
"/api/admin/auth",
|
||||
"/api/onboarding",
|
||||
"/api/ai",
|
||||
"/api/auth/debug",
|
||||
];
|
||||
|
||||
// Protected API routes that need authentication
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue