fix: pass original request headers to auth.api.getSession
This commit is contained in:
@@ -24,12 +24,7 @@ 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) {
|
||||||
// Use a plain Headers object to avoid any Request-header quirks
|
const session = await auth.api.getSession({ headers: request.headers });
|
||||||
const headers = new Headers();
|
|
||||||
const cookie = request.headers.get("cookie");
|
|
||||||
if (cookie) headers.set("cookie", cookie);
|
|
||||||
|
|
||||||
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 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,5 @@ import * as schema from "./schema";
|
|||||||
|
|
||||||
const connectionString = process.env.DATABASE_URL!;
|
const connectionString = process.env.DATABASE_URL!;
|
||||||
|
|
||||||
const client = postgres(connectionString, {
|
const client = postgres(connectionString);
|
||||||
debug: (connection, query, params, types) => {
|
export const db = drizzle(client, { schema, cache: new NoopCache() });
|
||||||
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() });
|
|
||||||
|
|||||||
Reference in New Issue
Block a user