fix: add debug endpoint
This commit is contained in:
parent
152bf2079c
commit
f7bcc97666
1 changed files with 30 additions and 0 deletions
30
src/app/api/debug/route.ts
Normal file
30
src/app/api/debug/route.ts
Normal 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);
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue