From 8f64ccd2f6fcb3d8bf5a5363d95d6a118141963c Mon Sep 17 00:00:00 2001 From: Christopher Mayor Date: Mon, 27 Apr 2026 12:05:50 -0700 Subject: [PATCH] fix: pass original request headers to auth.api.getSession --- src/app/api/compare/route.ts | 7 +------ src/lib/db/index.ts | 11 ++--------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/app/api/compare/route.ts b/src/app/api/compare/route.ts index 988e2a4..75e8dbc 100644 --- a/src/app/api/compare/route.ts +++ b/src/app/api/compare/route.ts @@ -24,12 +24,7 @@ function slugify(text: string): string { // const ratelimit = new Ratelimit({ redis, limiter: slidingWindow(5, "1m") }) export async function POST(request: Request) { - // Use a plain Headers object to avoid any Request-header quirks - const headers = new Headers(); - const cookie = request.headers.get("cookie"); - if (cookie) headers.set("cookie", cookie); - - const session = await auth.api.getSession({ headers }); + const session = await auth.api.getSession({ headers: request.headers }); if (!session?.user) { return Response.json({ error: "Authentication required" }, { status: 401 }); } diff --git a/src/lib/db/index.ts b/src/lib/db/index.ts index c9e0d28..3db18f6 100644 --- a/src/lib/db/index.ts +++ b/src/lib/db/index.ts @@ -5,12 +5,5 @@ import * as schema from "./schema"; const connectionString = process.env.DATABASE_URL!; -const client = postgres(connectionString, { - debug: (connection, query, params, types) => { - console.log("[postgres.js debug]", query, params); - }, - onnotice: (notice) => { - console.log("[postgres.js notice]", notice); - }, -}); -export const db = drizzle(client, { schema, logger: true, cache: new NoopCache() }); +const client = postgres(connectionString); +export const db = drizzle(client, { schema, cache: new NoopCache() });