fix: use plain Headers for auth session lookup in compare route
This commit is contained in:
@@ -24,13 +24,12 @@ function slugify(text: string): string {
|
|||||||
// const ratelimit = new Ratelimit({ redis, limiter: slidingWindow(5, "1m") })
|
// const ratelimit = new Ratelimit({ redis, limiter: slidingWindow(5, "1m") })
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
let session;
|
// Use a plain Headers object to avoid any Request-header quirks
|
||||||
try {
|
const headers = new Headers();
|
||||||
session = await auth.api.getSession({ headers: request.headers });
|
const cookie = request.headers.get("cookie");
|
||||||
} catch (e) {
|
if (cookie) headers.set("cookie", cookie);
|
||||||
console.error("[compare] getSession error:", e);
|
|
||||||
return Response.json({ error: "Session lookup failed", detail: String(e) }, { status: 500 });
|
const session = await auth.api.getSession({ headers });
|
||||||
}
|
|
||||||
if (!session?.user) {
|
if (!session?.user) {
|
||||||
return Response.json({ error: "Authentication required" }, { status: 401 });
|
return Response.json({ error: "Authentication required" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user