{"record":{"id":"b0138940dc849b98","repo":"astrid-runtime/astrid","slug":"cors-origin-raw-carries-a-path-origins","errorCode":null,"errorMessage":"CORS origin {raw:?} carries a path ({:?}); origins are scheme+host+port only","messagePattern":"CORS origin (.+?) carries a path \\((.+?)\\); origins are scheme\\+host\\+port only","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-gateway/src/config.rs","lineNumber":208,"sourceCode":"    match parsed.scheme() {\n        \"http\" | \"https\" => {},\n        other => anyhow::bail!(\n            \"CORS origin {raw:?} uses scheme {other:?}; only http/https are valid for browser origins\"\n        ),\n    }\n    if parsed.host_str().is_none() {\n        anyhow::bail!(\"CORS origin {raw:?} has no host component\");\n    }\n    // Browsers strip userinfo before sending `Origin:`, so a config\n    // entry with embedded credentials can never match a real\n    // preflight. Reject so operators don't silently misconfigure.\n    if !parsed.username().is_empty() || parsed.password().is_some() {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries userinfo (user:password); browsers strip it before sending `Origin:` so this can never match\"\n        );\n    }\n    if parsed.path() != \"\" && parsed.path() != \"/\" {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries a path ({:?}); origins are scheme+host+port only\",\n            parsed.path()\n        );\n    }\n    if parsed.query().is_some() || parsed.fragment().is_some() {\n        anyhow::bail!(\n            \"CORS origin {raw:?} carries a query/fragment; origins are scheme+host+port only\"\n        );\n    }\n    // Disallow trailing-slash forms — browsers send `https://app.example`\n    // (no slash) in `Origin:` and the response header is byte-matched.\n    if raw.ends_with('/') {\n        anyhow::bail!(\n            \"CORS origin {raw:?} has a trailing slash; remove it (browsers send `Origin:` without one)\"\n        );\n    }\n    // Reject a raw IDN — browsers transmit the Punycode (ASCII)\n    // form in `Origin:`, so the bytes wouldn't match anyway. The","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/config.rs#L190-L226","documentation":"Validation guard in validate_cors_origin: the entry contains a path component, but an origin is scheme+host+port only; browsers never send a path in Origin:, so the entry could never match and would silently break preflight handling.","triggerScenarios":"Thrown at crates/astrid-gateway/src/config.rs:208 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip the path from the entry, keeping only scheme://host[:port]","Move route-specific matching out of CORS config — CORS origins are not URL prefixes","Re-test browser preflight after correction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}