{
  "id": "python/fastapi-cors-not-enabled",
  "signature": "CORS error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.",
  "signature_zh": "CORS 错误：预检请求的响应未通过访问控制检查：请求的资源上不存在 'Access-Control-Allow-Origin' 标头。",
  "regex": "CORS\\ error:\\ Response\\ to\\ preflight\\ request\\ doesn't\\ pass\\ access\\ control\\ check:\\ No\\ 'Access\\-Control\\-Allow\\-Origin'\\ header\\ is\\ present\\ on\\ the\\ requested\\ resource\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "FastAPI 应用未启用 CORS 中间件，导致浏览器阻止跨域请求。",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI 应用未启用 CORS 中间件，导致浏览器阻止跨域请求。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "只处理了简单请求，预检请求（OPTIONS）仍然失败，且代码繁琐。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Flask-CORS 是 Flask 的扩展，不兼容 FastAPI，会导致导入错误。",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from fastapi.middleware.cors import CORSMiddleware\napp.add_middleware(CORSMiddleware, allow_origins=['*'], allow_methods=['*'], allow_headers=['*'])",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}