Skip to content

Commit c62789b

Browse files
make credit check non-fatal in proxy
The credit_balance_eur column may not exist in all environments. Fail open so the proxy still works while the schema catches up. Made-with: Cursor
1 parent d1d3552 commit c62789b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/app/api/gateway/proxy/route.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ export async function POST(request: NextRequest) {
106106

107107
const { instanceId, orgId } = resolved
108108

109-
const hasFunds = await checkSufficientBalance(orgId, 0.001)
110-
if (!hasFunds) {
111-
return NextResponse.json(
112-
{ error: 'Insufficient credit balance. Please add credits.' },
113-
{ status: 402 },
114-
)
109+
try {
110+
const hasFunds = await checkSufficientBalance(orgId, 0.001)
111+
if (!hasFunds) {
112+
return NextResponse.json(
113+
{ error: 'Insufficient credit balance. Please add credits.' },
114+
{ status: 402 },
115+
)
116+
}
117+
} catch (err) {
118+
console.warn('Credit check failed, allowing request:', err)
115119
}
116120

117121
let requestBody: Record<string, unknown>

0 commit comments

Comments
 (0)