A Symfony bundle that adds CORS headers to responses and handles preflight requests with per-URL configuration.
NelmioCorsBundle is a Symfony bundle that implements Cross-Origin Resource Sharing (CORS) support for Symfony applications. It solves the problem of enabling secure cross-origin HTTP requests by automatically adding CORS headers to responses and handling preflight OPTIONS requests. This allows web applications to safely interact with APIs hosted on different domains.
Symfony developers building web applications or APIs that need to handle requests from different origins, particularly those creating RESTful APIs consumed by JavaScript applications.
Developers choose NelmioCorsBundle because it provides native, well-integrated CORS support for Symfony with flexible per-URL configuration, eliminating the need to manually handle CORS headers or rely on web server configuration for application-level CORS policies.
Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically handles CORS preflight OPTIONS requests, eliminating the need for manual implementation and reducing boilerplate code in Symfony applications.
Supports ACL-style per-URL configuration, allowing developers to define precise CORS policies for different endpoints, origins, and methods as outlined in the documentation.
Integrates natively with Symfony's request-response lifecycle, enabling easy setup via Flex or manual bundle registration and configuration through standard Symfony practices.
Provides CORS header injection at the PHP level, allowing dynamic policy adjustments based on application logic rather than static web server settings.
As admitted in the README, it does not add CORS headers to static files served outside Symfony, requiring additional web server or CDN configuration for full coverage.
Tightly coupled with Symfony, making it unsuitable for projects using other frameworks or non-Symfony ecosystems, leading to vendor lock-in.
The ACL-style configuration can be complex and verbose for simple use cases, compared to more straightforward web server directives or minimal middleware solutions.