{
  "id": "nextjs/invalid-middleware-matcher-regex",
  "signature": "Error: Invalid middleware matcher. The pattern 'X' is not a valid regex or path pattern.",
  "signature_zh": "错误：无效的中间件匹配器。模式 'X' 不是有效的正则表达式或路径模式。",
  "regex": "Error: Invalid middleware matcher\\. The pattern '.*' is not a valid regex or path pattern",
  "domain": "nextjs",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The matcher array in middleware.config contains a malformed regex or path pattern that Next.js cannot parse.",
  "root_cause_type": "generic",
  "root_cause_zh": "middleware.config 中的匹配器数组包含一个格式错误的正则表达式或路径模式，Next.js 无法解析。",
  "versions": [
    {
      "version": "next@13.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Next.js matcher patterns use a simplified glob syntax, not full regex. Forward slashes are reserved for path segments.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Characters like '.' or '*' need escaping in regex but Next.js matcher uses glob where '*' is a wildcard, causing ambiguity.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "An empty array matches no routes, effectively disabling the middleware, which may not be the intended behavior.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use the correct glob syntax for path matching. For example, to match all API routes:\n\nexport const config = {\n  matcher: '/api/:path*',\n};\n\nFor multiple patterns, use an array:\nexport const config = {\n  matcher: ['/api/:path*', '/admin/:path*'],\n};",
      "success_rate": 0.95,
      "how": "Use the correct glob syntax for path matching. For example, to match all API routes:\n\nexport const config = {\n  matcher: '/api/:path*',\n};\n\nFor multiple patterns, use an array:\nexport const config = {\n  matcher: ['/api/:path*', '/admin/:path*'],\n};",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need complex matching, use a custom middleware function that checks the request URL manually instead of relying on matcher.",
      "success_rate": 0.85,
      "how": "If you need complex matching, use a custom middleware function that checks the request URL manually instead of relying on matcher.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Validate your pattern using the Next.js documentation: patterns use a simplified glob where '*' matches any path segment and ':param' captures named parameters.",
      "success_rate": 0.9,
      "how": "Validate your pattern using the Next.js documentation: patterns use a simplified glob where '*' matches any path segment and ':param' captures named parameters.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用正确的 glob 语法进行路径匹配。例如，匹配所有 API 路由：\n\nexport const config = {\n  matcher: '/api/:path*',\n};\n\n对于多个模式，使用数组：\nexport const config = {\n  matcher: ['/api/:path*', '/admin/:path*'],\n};",
    "如果需要复杂匹配，使用自定义中间件函数手动检查请求 URL，而不是依赖匹配器。",
    "使用 Next.js 文档验证你的模式：模式使用简化的 glob，其中 '*' 匹配任何路径段，':param' 捕获命名参数。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}