A Laravel middleware package for handling Cross-Origin Resource Sharing (CORS) headers and pre-flight requests.
laravel-cors is a middleware package for Laravel that handles Cross-Origin Resource Sharing (CORS) headers and pre-flight OPTIONS requests. It solves the problem of enabling secure cross-origin API requests from web browsers by automatically adding the necessary CORS headers to responses and managing pre-flight checks.
Laravel and Lumen developers building RESTful APIs or web services that need to be consumed by frontend applications hosted on different domains or subdomains.
Developers choose this package because it provides a robust, configurable, and framework-integrated solution for CORS handling, eliminating the need to manually manage CORS headers or write custom middleware. It follows Laravel conventions and offers detailed configuration options for complex cross-origin scenarios.
Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
Automatically responds to OPTIONS requests with correct CORS headers, eliminating manual pre-flight code, as stated in the README's features.
Offers extensive config options for paths, origins, headers, and methods via a dedicated config file, allowing precise security policies.
Provides full compatibility with Lumen through service provider registration, which lacks built-in CORS middleware.
Configurable to include Access-Control-Allow-Credentials header, essential for APIs using authorization headers or cookies.
The package is deprecated since Laravel 9.2 includes CORS middleware in core, making it unnecessary and unsupported for current projects.
Requires careful setup of paths and headers; misconfiguration leads to CORS errors, as highlighted in the 'Common problems' section.
Upgrading from older versions involved significant changes, such as new path properties and vendor name shifts, causing migration headaches.
CORS headers can fail if middleware order is incorrect or if other middleware interrupts the flow, requiring debugging expertise.
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Debugbar for Laravel (Integrates PHP Debug Bar)
IDE Helper for Laravel
PHP Image Processing
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.