{
  "id": "python/fastapi-cors-header-missing",
  "signature": "Access to fetch at 'http://localhost:8000/api' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.",
  "signature_zh": "从源 'http://localhost:3000' 访问 'http://localhost:8000/api' 的 fetch 被 CORS 策略阻止：请求的资源上没有 'Access-Control-Allow-Origin' 响应头。",
  "regex": "Access\\ to\\ fetch\\ at\\ 'http://localhost:8000/api'\\ from\\ origin\\ 'http://localhost:3000'\\ has\\ been\\ blocked\\ by\\ CORS\\ policy:\\ No\\ 'Access\\-Control\\-Allow\\-Origin'\\ header\\ is\\ present\\ on\\ the\\ requested\\ resource\\.",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "CORSMiddleware is not installed or does not include the requesting origin, so the browser blocks the response.",
  "root_cause_type": "generic",
  "root_cause_zh": "未安装 CORSMiddleware 或其允许的源不包含请求来源，因此浏览器阻止了响应。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Browsers reject wildcard origin when credentials are included.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Not possible for end users; only a local dev flag.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from fastapi.middleware.cors import CORSMiddleware\napp.add_middleware(CORSMiddleware, allow_origins=['http://localhost:3000'], allow_credentials=True, allow_methods=['*'], allow_headers=['*'])",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "app.add_middleware(CORSMiddleware, allow_origin_regex=r'https://.*\\.example\\.com')",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}