{
  "id": "python/flask-cors-no-access-control-allow-origin",
  "signature": "Access to XMLHttpRequest at 'http://api.local/users' from origin 'http://frontend.local' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.",
  "signature_zh": "CORS 策略阻止了跨域请求：响应中缺少 'Access-Control-Allow-Origin' 头。",
  "regex": "Access\\ to\\ XMLHttpRequest\\ at\\ 'http://api\\.local/users'\\ from\\ origin\\ 'http://frontend\\.local'\\ 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": "Server did not return CORS headers for the origin, or flask-cors was configured with resources that exclude the path.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务器未为来源返回 CORS 头，或 flask-cors 配置的 resources 排除了该路径。",
  "versions": [
    {
      "version": "4.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Fails with credentials=true; browsers reject wildcard with credentials.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Error responses (4xx/5xx) still lack headers; browser blocks them.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from flask_cors import CORS\nCORS(app, resources={r\"/api/*\": {\"origins\": \"https://frontend.local\"}}, supports_credentials=True)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ensure `@app.after_request` adds headers even on error: def add_cors(resp): resp.headers['Access-Control-Allow-Origin']=origin; return resp",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}