diff --git a/lib/security/request-monitor.ts b/lib/security/request-monitor.ts index 6224974..1a8ac62 100644 --- a/lib/security/request-monitor.ts +++ b/lib/security/request-monitor.ts @@ -42,6 +42,23 @@ export function isSuspiciousRequest(request: Request): { const pathname = url.pathname; const method = request.method; + // 排除正常的应用路径(避免误报) + const allowedPaths = [ + "/api/admin/", // 管理后台API(正常功能) + "/api/", // 所有API路径(正常功能) + "/chat/", // 聊天页面 + "/gallery/", // 相册页面 + "/settings/", // 设置页面 + "/login", // 登录页面 + "/register", // 注册页面 + ]; + + // 如果是正常的应用路径,不标记为可疑 + const isAllowedPath = allowedPaths.some(allowed => pathname.startsWith(allowed)); + if (isAllowedPath) { + return { suspicious: false }; + } + // 检查可疑路径 for (const pattern of SUSPICIOUS_PATHS) { if (pathname.includes(pattern)) { @@ -120,3 +137,4 @@ export async function validateRequestBody( +