From 00f893e318e55ad12f494464b4757799e97a3f50 Mon Sep 17 00:00:00 2001 From: Adam Gough <77861281+aadamgough@users.noreply.github.com> Date: Sun, 8 Jun 2025 18:19:44 -0700 Subject: [PATCH] fix(telegram-middleware): modified middleware to not check for user-agent on webhook fix(telegram-middleware): modified middleware to not check for user-agent on webhook --- apps/sim/middleware.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/sim/middleware.ts b/apps/sim/middleware.ts index 1a7f9ea498..6e958c91d1 100644 --- a/apps/sim/middleware.ts +++ b/apps/sim/middleware.ts @@ -99,8 +99,14 @@ export async function middleware(request: NextRequest) { } const userAgent = request.headers.get('user-agent') || '' + + // Check if this is a webhook endpoint that should be exempt from User-Agent validation + const isWebhookEndpoint = url.pathname.startsWith('/api/webhooks/trigger/') + const isSuspicious = SUSPICIOUS_UA_PATTERNS.some((pattern) => pattern.test(userAgent)) - if (isSuspicious) { + + // Block suspicious requests, but exempt webhook endpoints from User-Agent validation only + if (isSuspicious && !isWebhookEndpoint) { logger.warn('Blocked suspicious request', { userAgent, ip: request.headers.get('x-forwarded-for') || 'unknown',