debug: add error catching to compare getSession
This commit is contained in:
@@ -24,7 +24,13 @@ function slugify(text: string): string {
|
||||
// const ratelimit = new Ratelimit({ redis, limiter: slidingWindow(5, "1m") })
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const session = await auth.api.getSession({ headers: request.headers });
|
||||
let session;
|
||||
try {
|
||||
session = await auth.api.getSession({ headers: request.headers });
|
||||
} catch (e) {
|
||||
console.error("[compare] getSession error:", e);
|
||||
return Response.json({ error: "Session lookup failed", detail: String(e) }, { status: 500 });
|
||||
}
|
||||
if (!session?.user) {
|
||||
return Response.json({ error: "Authentication required" }, { status: 401 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user