Laravel Cors

screenshot of Laravel Cors

Send CORS headers in a Laravel application

Overview:

The Spatie Laravel CORS package is designed to add Cross-Origin Resource Sharing (CORS) headers to responses in your Laravel or Lumen application. The package offers support for preflight requests and allows for easy configuration to suit your specific needs.

Features:

  • CORS Headers: Automatically adds CORS headers to Laravel or Lumen app responses.
  • Preflight Requests: Supports preflight requests for enhanced compatibility.
  • Customizable Configuration: Easily configurable to specify allowed origins and customize CORS profiles.

Laravel:

Install the package via Composer:

composer require spatie/laravel-cors

The package will auto-register its service provider. Register the provided Spatie\Cors\Cors middleware in the global middleware group. The default configuration file will be available at config/cors.php.

Lumen:

Install the package via Composer: