diff --git a/apps/web/modules/api/v2/auth/api-wrapper.ts b/apps/web/modules/api/v2/auth/api-wrapper.ts index 47326050f8..e03d2abc75 100644 --- a/apps/web/modules/api/v2/auth/api-wrapper.ts +++ b/apps/web/modules/api/v2/auth/api-wrapper.ts @@ -67,7 +67,21 @@ export const apiWrapper = async ({ let parsedInput: ParsedSchemas = {} as ParsedSchemas; if (schemas?.body) { - const bodyData = await request.json(); + let bodyData; + try { + bodyData = await request.json(); + } catch (error) { + return handleApiError(request, { + type: "bad_request", + details: [ + { + field: "error", + issue: "Malformed JSON input, please check your request body", + }, + ], + }); + } + const bodyResult = schemas.body.safeParse(bodyData); if (!bodyResult.success) {