Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(invite): handle invalid JSON body gracefully in accept route

Richie McIlroyc6fd14a399f7
diff --git a/apps/web/app/api/invite/accept/route.ts b/apps/web/app/api/invite/accept/route.ts
index aae8e3c3a..e60ecc437 100644
--- a/apps/web/app/api/invite/accept/route.ts
+++ b/apps/web/app/api/invite/accept/route.ts
@@ -17,7 +17,15 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
- const { inviteId } = await request.json();
+ let inviteId: unknown;
+ try {
+ ({ inviteId } = await request.json());
+ } catch {
+ return NextResponse.json(
+ { error: "Invalid request body" },
+ { status: 400 },
+ );
+ }
if (typeof inviteId !== "string" || !inviteId) {
return NextResponse.json({ error: "Invalid invite ID" }, { status: 400 });