asm89/stack-cors
Stack CORS is a middleware for StackPHP and Symfony HttpKernel apps that adds Cross-Origin Resource Sharing headers, handles preflight OPTIONS requests, and offers configurable origins, methods, headers, and credentials. Widely used and easy to integrate.
Vary headers, credentialed-request rules, wildcard-with-exceptions, and origin reflection are all easy to get subtly and dangerously wrong. A 1.2k-star MIT library that already underpins mainstream Laravel CORS packages is a "buy" with near-zero procurement cost.Consider it when:
Look elsewhere or do not adopt directly when:
fruitcake/php-cors), and older barryvdh/fruitcake Laravel CORS packages pulled asm89/stack-cors in transitively. In that case your decision is "accept it as a transitive dependency," not "adopt it." Verify against composer.lock before you write it into an ADR.Access-Control-Allow-Origin: *. Edge/CDN or gateway configuration is cheaper and closer to the traffic.For executives (30 seconds): This is small, free (MIT), widely used plumbing that already sits underneath the CORS packages in most Laravel stacks. Adopting it is a dependency decision, not a project — roughly zero cost, low risk, no lock-in. Its value is defensive: it lets us safely open our APIs to browser clients on other domains — partner portals, embedded widgets, customer-hosted frontends — without hand-rolling security-sensitive header logic. It is infrastructure, not a differentiator; approve it as a dependency and move the roadmap conversation to which origins we choose to allow.
For engineering: Don't hand-roll preflight logic. Centralize the allow-list and policy in configuration, treat origin lists as reviewed config rather than code, and add tests for credentialed requests, origin reflection, and Vary behavior. Pin the version, watch advisories, and confirm whether the framework already provides this transitively before adding a direct dependency. Budget a short spike to map the dependency path and produce a one-page CORS policy owned by a named team.
How can I help you explore Laravel packages today?