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
This commit is contained in:
Adam Gough
2025-06-08 18:19:44 -07:00
committed by GitHub
parent 567f7a5e10
commit 00f893e318

View File

@@ -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',