Skip to content

Commit 07bfb6d

Browse files
IMMINJUclaude
andcommitted
Fix Neon URL cleanup and add health error details
Use URL API instead of regex for reliable channel_binding removal. Add error message to health endpoint for debugging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 48f419e commit 07bfb6d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/app/api/health/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ export async function GET() {
66
try {
77
await db.execute(sql`SELECT 1`)
88
return NextResponse.json({ status: 'ok' })
9-
} catch {
10-
return NextResponse.json({ status: 'error' }, { status: 503 })
9+
} catch (error) {
10+
return NextResponse.json(
11+
{ status: 'error', message: error instanceof Error ? error.message : 'Unknown error' },
12+
{ status: 503 }
13+
)
1114
}
1215
}

src/db/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ function getDb() {
1313
}
1414

1515
// Strip channel_binding param (unsupported by postgres.js, added by Neon)
16-
const cleanedUrl = connectionString.replace(/[?&]channel_binding=[^&]*/g, '')
16+
const url = new URL(connectionString)
17+
url.searchParams.delete('channel_binding')
18+
const cleanedUrl = url.toString()
1719

1820
const isProduction = process.env.NODE_ENV === 'production'
1921

0 commit comments

Comments
 (0)