Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(api): handle invalid JSON in credits checkout route

Richie McIlroye5e493bed815
diff --git a/apps/web/app/api/developer/credits/checkout/route.ts b/apps/web/app/api/developer/credits/checkout/route.ts
index 5e007b756..9838fd470 100644
--- a/apps/web/app/api/developer/credits/checkout/route.ts
+++ b/apps/web/app/api/developer/credits/checkout/route.ts
@@ -17,7 +17,14 @@ export async function POST(request: NextRequest) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
- const { appId, amountCents } = await request.json();
+ let body: { appId?: string; amountCents?: number };
+ try {
+ body = await request.json();
+ } catch {
+ return Response.json({ error: "Invalid JSON body" }, { status: 400 });
+ }
+
+ const { appId, amountCents } = body;
if (
!appId ||