fix: add debug endpoint

This commit is contained in:
Manohar Gupta 2026-05-10 04:51:35 +05:30
parent 152bf2079c
commit f7bcc97666

View file

@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
export async function GET() {
const results: Record<string, string> = {};
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);
}