What problem does it solve?
Browsers block or restrict cross-origin requests when CORS is misconfigured, causing frontend failures, broken authentication flows, and inadvertent exposure of endpoints. This guidance helps teams avoid common CORS mistakes and safely enable only the cross-origin interactions their clients require.
Core Features & Use Cases
- Least-privilege allowlists for origins, methods, and headers to reduce attack surface.
- Credential-safe configuration that prevents wildcard origins when cookies or authorization headers are used.
- Named policies and per-endpoint application so different API groups (public vs authenticated) get appropriate rules.
- Middleware ordering and preflight caching recommendations, plus environment-specific configuration patterns and an options class for strong typing.
- Use cases: browser-based SPA on a different origin, third-party front-ends calling public endpoints, development servers on alternate ports, and scenarios requiring subdomain support.
Quick Start
Configure a restrictive CORS policy that allows only https://app.example.com, enables credentials for authenticated SPA requests, and applies the policy to the API endpoints that serve the SPA.