From 5537a076a59630b51a45705d8c2581a1bee3ec39 Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Sun, 19 May 2024 16:09:16 +0100 Subject: [PATCH] login-account-proxy: Better handle slightly malformed payloads from Bubble --- apps/login-account-proxy/src/pages/api/public/submit.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/login-account-proxy/src/pages/api/public/submit.ts b/apps/login-account-proxy/src/pages/api/public/submit.ts index 62c9d58..3f2d1d0 100644 --- a/apps/login-account-proxy/src/pages/api/public/submit.ts +++ b/apps/login-account-proxy/src/pages/api/public/submit.ts @@ -15,8 +15,9 @@ export default apiRoute(async ( res: NextApiResponse, ) => { // TODO: better schema validation - const data = req.body as SubmitRequest; + const data = (typeof req.body === 'string' ? JSON.parse(req.body) : req.body) as SubmitRequest; if (typeof data.newEmail !== 'string' || typeof data.password !== 'string' || typeof data.secret !== 'string') { + console.error(`Invalid payload: ${JSON.stringify(req.body)}`); res.status(400).send({ type: 'error', message: 'Invalid payload' }); return; }