fix(cors): split CORS_ORIGIN comma-list into per-origin registrations #46
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
psa-systems/bunyip!46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/cors-allowed-origins-list"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The CorsLayer wiring assumed CORS_ORIGIN was a single absolute URL:
let cors_origin = config.cors_origin.clone(); // entire "https://a8n.systems,https://msp.a8n.systems,..." string
.allowed_origin(&cors_origin) // never matches a real Origin header
.split("://").nth(1).unwrap_or("") // yields "a8n.systems,https" on a comma-list
Once the bunyip-as-OP cutover landed three browser RPs (bunyip-web, mokosh-apps,
drillmark), the comma-list silently broke CORS for every cross-origin browser
hit to bunyip-api. The SPA's POST to /oauth2/token surfaced as a TypeError:
Failed to fetch on the /auth/callback page because the preflight had no
matching allowed origin.
Parse CORS_ORIGIN as comma-separated, register each entry via
cors.allowed_origin(o) in turn. Switch the subdomain-fallback domain derivation
to BUNYIP_WEB_ORIGIN (which is always a single URL) so the closure isn't fed
a comma-list either.