{
  "id": "nextjs/middleware-redirect-to-internal-with-query",
  "signature": "Error: Middleware redirected to a URL with a query string. Redirects must be to pathnames only.",
  "signature_zh": "错误：中间件重定向到了包含查询字符串的 URL。重定向必须仅指向路径名。",
  "regex": "Middleware redirected to a URL with a query string",
  "domain": "nextjs",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "In Next.js middleware, the `redirect` method (from NextResponse) expects a pathname string without query parameters. Passing a URL with a query string causes an internal error.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Next.js 中间件中，`redirect` 方法（来自 NextResponse）期望一个不带查询参数的路径名字符串。传递带有查询字符串的 URL 会导致内部错误。",
  "versions": [
    {
      "version": "Next.js 13.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 14.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 15.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The redirect function does not support query strings; it strips them or throws an error.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "NextResponse.redirect internally validates the URL; setting headers directly bypasses this but may cause hydration or caching issues.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Rewrite changes the URL server-side but does not cause a client-side redirect, which may not achieve the desired navigation.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Redirect to a pathname without query strings, then handle query parameters client-side using useSearchParams or server-side in the target page.",
      "success_rate": 0.9,
      "how": "Redirect to a pathname without query strings, then handle query parameters client-side using useSearchParams or server-side in the target page.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use NextResponse.redirect with a path and then append query parameters via a server-side rewrite or client-side navigation.",
      "success_rate": 0.85,
      "how": "Use NextResponse.redirect with a path and then append query parameters via a server-side rewrite or client-side navigation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Redirect to a pathname without query strings, then handle query parameters client-side using useSearchParams or server-side in the target page.",
    "Use NextResponse.redirect with a path and then append query parameters via a server-side rewrite or client-side navigation."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/building-your-application/routing/middleware#redirecting",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-03-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}