fix(attachment-counts api): surface real error details instead of generic PB admin message
capture the thrown error, extract its message if available, and append it to the base "PB admin unavailable" error response. fall back to a generic unknown error message for non-Error failures, revealing actionable debugging details like missing env vars or invalid PB credentials.
This commit is contained in:
parent
05abe499b0
commit
235c0ad39b
1 changed files with 7 additions and 2 deletions
|
|
@ -42,9 +42,14 @@ export async function GET(req: NextRequest) {
|
|||
let adminPb;
|
||||
try {
|
||||
adminPb = await getAdminPocketBase();
|
||||
} catch {
|
||||
} catch (err) {
|
||||
// Surface the real reason — the generic "PB admin unavailable"
|
||||
// message was hiding the actual cause (missing env var, wrong
|
||||
// password, PB unreachable from the prod container, etc.).
|
||||
const reason =
|
||||
err instanceof Error ? err.message : "unknown admin error";
|
||||
return NextResponse.json(
|
||||
{ error: "PB admin unavailable" },
|
||||
{ error: `PB admin unavailable: ${reason}` },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue