From 9149af7e6bcb4aebc77efb3c9e7e2317ff15ffac Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 22 Dec 2022 09:38:17 +0100 Subject: [PATCH] :bug: (webhook) Fix form encoded request parsing Was not working when setting `Content-Type` header to `application/x-www-form-urlencoded` --- .../[typebotId]/blocks/[blockId]/executeWebhook.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts index 838cedc90..58c66751e 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts @@ -140,10 +140,13 @@ export const executeWebhook = headers, ...basicAuth, json: - contentType !== 'x-www-form-urlencoded' && body && isJson + !contentType?.includes('x-www-form-urlencoded') && body && isJson + ? body + : undefined, + form: + contentType?.includes('x-www-form-urlencoded') && body ? body : undefined, - form: contentType === 'x-www-form-urlencoded' && body ? body : undefined, body: body && !isJson ? body : undefined, } try {