{
  "id": "python/fastapi-cors-preflight-blocked",
  "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' 被 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": "FastAPI/Starlette app has no `CORSMiddleware`, or the middleware was added after routes / with wrong origins.",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI/Starlette 应用未添加 `CORSMiddleware`，或中间件在路由之后添加、允许的源配置错误。",
  "versions": [
    {
      "version": "0.100+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Not viable for end users; masks server config bug.",
      "fail_rate": 0.99,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Preflight OPTIONS is handled before route; header missing on OPTIONS.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "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.93,
      "how": "allow_origins=os.environ['ALLOWED_ORIGINS'].split(',')",
      "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-02-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}