From f7bcc976666728ac34a713c999589e59e1d87f54 Mon Sep 17 00:00:00 2001 From: Mannu Date: Sun, 10 May 2026 04:51:35 +0530 Subject: [PATCH] fix: add debug endpoint --- src/app/api/debug/route.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/app/api/debug/route.ts diff --git a/src/app/api/debug/route.ts b/src/app/api/debug/route.ts new file mode 100644 index 0000000..b780c33 --- /dev/null +++ b/src/app/api/debug/route.ts @@ -0,0 +1,30 @@ +import { NextResponse } from "next/server"; + +export async function GET() { + const results: Record = {}; + + try { + // Test without using DATABASE_URL directly + const { default: postgres } = await import("postgres"); + + const connectionString = process.env.DATABASE_URL || ""; + results["env_exists"] = connectionString ? "yes" : "no"; + results["env_value"] = connectionString; + + // Try connection + if (connectionString) { + const client = postgres(connectionString); + await client.connect(); + results["connect"] = "success"; + + const result = await client`SELECT version()`; + results["version"] = result[0]?.version?.slice(0, 50) || "ok"; + + await client.end(); + } + } catch (err: any) { + results["error"] = err.message || String(err); + } + + return NextResponse.json(results); +} \ No newline at end of file