@dana
To enable CORS in Laravel, you can use the barryvdh/laravel-cors package. Here's how you can do it:
1
|
composer require barryvdh/laravel-cors |
1 2 3 4 5 |
'providers' => [ ... BarryvdhCorsServiceProvider::class, ... ] |
1
|
php artisan vendor:publish --provider="BarryvdhCorsServiceProvider" |
This will create a new cors.php
configuration file in your config
directory.
1 2 3 4 5 6 7 8 |
'paths' => ['api/*'], 'allowed_methods' => ['GET', 'POST', 'PUT', 'DELETE'], 'allowed_origins' => ['*'], 'allowed_origins_patterns' => [], 'allowed_headers' => ['Content-Type', 'X-Requested-With'], 'exposed_headers' => [], 'max_age' => 0, 'supports_credentials' => false, |
You can customize these settings based on your specific requirements.