{
  "id": "grpc/grpc-web-cors-origin-mismatch",
  "signature": "INTERNAL: grpc-web: CORS preflight failed for origin http://example.com: allowed origins: [http://localhost:3000]",
  "signature_zh": "内部错误：gRPC-Web：来源 http://example.com 的 CORS 预检失败：允许的来源：[http://localhost:3000]",
  "regex": "INTERNAL: grpc-web: CORS preflight failed for origin https?://\\S+: allowed origins: \\[.*\\]",
  "domain": "grpc",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The gRPC-Web proxy's CORS configuration does not include the requesting origin, causing the browser to block the preflight request and preventing the gRPC call from proceeding.",
  "root_cause_type": "generic",
  "root_cause_zh": "gRPC-Web 代理的 CORS 配置未包含请求来源，导致浏览器阻止预检请求并阻止 gRPC 调用继续进行。",
  "versions": [
    {
      "version": "gRPC-Web v1.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Envoy 1.27.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gRPC v1.60.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling CORS entirely in the browser (e.g., using a flag) is insecure and not a production solution.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing the client origin in the browser's developer tools does not persist and is not a real fix.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding a wildcard '*' to allowed origins may work but exposes the service to any origin, creating security risks.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Update the Envoy or gRPC-Web proxy configuration to include the requesting origin: in Envoy, add `allowed_origins: [\"http://example.com\"]` to the CORS filter.",
      "success_rate": 0.9,
      "how": "Update the Envoy or gRPC-Web proxy configuration to include the requesting origin: in Envoy, add `allowed_origins: [\"http://example.com\"]` to the CORS filter.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a reverse proxy like Nginx to handle CORS headers: `add_header Access-Control-Allow-Origin \"http://example.com\" always;`",
      "success_rate": 0.85,
      "how": "Use a reverse proxy like Nginx to handle CORS headers: `add_header Access-Control-Allow-Origin \"http://example.com\" always;`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Temporarily enable a wildcard origin for development: in Envoy config, set `allowed_origins: [\"*\"]` but revert for production.",
      "success_rate": 0.75,
      "how": "Temporarily enable a wildcard origin for development: in Envoy config, set `allowed_origins: [\"*\"]` but revert for production.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "更新 Envoy 或 gRPC-Web 代理配置以包含请求来源：在 Envoy 中，将 `allowed_origins: [\"http://example.com\"]` 添加到 CORS 过滤器。",
    "使用反向代理（如 Nginx）处理 CORS 标头：`add_header Access-Control-Allow-Origin \"http://example.com\" always;`",
    "临时启用通配符来源用于开发：在 Envoy 配置中设置 `allowed_origins: [\"*\"]`，但生产环境需恢复。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://github.com/grpc/grpc-web/blob/master/doc/cors.md",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2024-07-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}