2
0

(webhook) Add Orimon in long request whitelist

This commit is contained in:
Baptiste Arnaud
2023-12-13 10:55:04 +01:00
parent 5e019bbb22
commit 3bd07c60da
2 changed files with 19 additions and 4 deletions

View File

@ -27,6 +27,11 @@ import {
defaultWebhookAttributes,
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
import { getBlockById } from '@typebot.io/lib/getBlockById'
import {
longReqTimeoutWhitelist,
longRequestTimeout,
responseDefaultTimeout,
} from '@typebot.io/bot-engine/blocks/integrations/webhook/executeWebhookBlock'
const cors = initMiddleware(Cors())
@ -156,10 +161,16 @@ export const executeWebhook =
)
: { data: undefined, isJson: false }
const url = parseVariables(variables)(
webhook.url + (queryParams !== '' ? `?${queryParams}` : '')
)
const isLongRequest = longReqTimeoutWhitelist.some((whiteListedUrl) =>
url?.includes(whiteListedUrl)
)
const request = {
url: parseVariables(variables)(
webhook.url + (queryParams !== '' ? `?${queryParams}` : '')
),
url,
method: (webhook.method ?? defaultWebhookAttributes.method) as Method,
headers: headers ?? {},
...basicAuth,
@ -172,6 +183,9 @@ export const executeWebhook =
? body
: undefined,
body: body && !isJson ? body : undefined,
timeout: {
response: isLongRequest ? longRequestTimeout : responseDefaultTimeout,
},
}
try {
const response = await got(request.url, omit(request, 'url'))