{
  "id": "nextjs/rewrite-invalid-destination",
  "signature": "Error: Invalid rewrite destination. Rewrite destination must be a relative path or an absolute URL within the same application.",
  "signature_zh": "错误：无效的重写目标。重写目标必须是相对路径或同一应用程序内的绝对 URL。",
  "regex": "Invalid rewrite destination|Rewrite destination must be a relative path",
  "domain": "nextjs",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A rewrite rule in next.config.js has a `destination` that points to an external URL (e.g., https://other-site.com) or an invalid path, but rewrites in Next.js are only allowed to redirect to internal routes within the same application.",
  "root_cause_type": "generic",
  "root_cause_zh": "next.config.js 中的重写规则有一个指向外部 URL（例如 https://other-site.com）或无效路径的 `destination`，但 Next.js 中的重写只允许重定向到同一应用程序内的内部路由。",
  "versions": [
    {
      "version": "Next.js 13.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 14.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 14.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The destination is still external; Next.js does not allow rewrites to external URLs regardless of formatting.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Redirects to external URLs are allowed, but if the intent was to proxy content (rewrite), this changes the URL in the browser, which may not be desired.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The basePath option only affects the application's own URL prefix, not rewrite destinations; the error will persist.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Change the destination to a relative path within the app. Example: `rewrites: async () => [{ source: '/old-path', destination: '/new-path' }]`. If you need to proxy an external API, use an API route instead.",
      "success_rate": 0.95,
      "how": "Change the destination to a relative path within the app. Example: `rewrites: async () => [{ source: '/old-path', destination: '/new-path' }]`. If you need to proxy an external API, use an API route instead.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If proxying an external API is required, create an API route that fetches from the external URL and returns the response. Example: In app/api/proxy/route.ts, use `fetch('https://other-site.com/api/data')` and return the result.",
      "success_rate": 0.9,
      "how": "If proxying an external API is required, create an API route that fetches from the external URL and returns the response. Example: In app/api/proxy/route.ts, use `fetch('https://other-site.com/api/data')` and return the result.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use middleware to rewrite requests to external URLs by returning a Response object with the external content. Example: In middleware.ts, `return fetch('https://other-site.com' + request.nextUrl.pathname)`.",
      "success_rate": 0.8,
      "how": "Use middleware to rewrite requests to external URLs by returning a Response object with the external content. Example: In middleware.ts, `return fetch('https://other-site.com' + request.nextUrl.pathname)`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将目标更改为应用程序内的相对路径。示例：`rewrites: async () => [{ source: '/old-path', destination: '/new-path' }]`。如果需要代理外部 API，请改用 API 路由。",
    "如果需要代理外部 API，请创建一个从外部 URL 获取数据并返回响应的 API 路由。示例：在 app/api/proxy/route.ts 中，使用 `fetch('https://other-site.com/api/data')` 并返回结果。",
    "使用中间件通过返回包含外部内容的 Response 对象来重写请求到外部 URL。示例：在 middleware.ts 中，`return fetch('https://other-site.com' + request.nextUrl.pathname)`。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/api-reference/next-config-js/rewrites",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-07-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}