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