mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user