spatie / laravel-cors

Send CORS headers in a Laravel application
https://spatie.be/en/opensource/laravel
MIT License
603 stars 59 forks source link

Lumen installation instructions probably require registering the cors config #79

Closed michaelschofield closed 4 years ago

michaelschofield commented 4 years ago

I ran into a similar issue that folks discussed in #71, where after following the instructions for Lumen use, I get

In InvalidCorsProfile.php line 10:

Argument 1 passed to Spatie\Cors\Exception\InvalidCorsProfile::profileDoesNotExtendDefaultProfile() must be of the type string, null given, called in /app/vendor/spatie/laravel-cors/src/CorsServiceProvider.php on line 23                                                                                                                                                                   

What was missing on my end was that after

  1. Copying the cors.php config into the config directory
  2. registering CorsServiceProvider and the Cors middleware in the app's bootstrap file,

I had to tell Lumen about the new config file.

$app->configure('cors');
freekmurze commented 4 years ago

Feel free to send a PR to update the readme with this info 👍