fix: pass ISO string not Date object to sql.unsafe for expires_at

postgres.js sql.unsafe() doesn't serialize Date objects in parameterized
queries — caused TypeError crashing the invite creation endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Manohar Gupta 2026-05-24 01:55:48 +05:30
parent 21f88459d7
commit 9f7ab870ba

View file

@ -26,7 +26,7 @@ export async function POST(
// Cryptographically random 32-byte token (64 hex chars) — unguessable // Cryptographically random 32-byte token (64 hex chars) — unguessable
const token = randomBytes(32).toString("hex"); const token = randomBytes(32).toString("hex");
const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(); // 7 days
const [invite] = await sql.unsafe( const [invite] = await sql.unsafe(
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at) `INSERT INTO circle_invites (circle_id, token, created_by, expires_at)