Shift with red gradient lettering Skip to content

Common Errors

Laravel: CORS config allowed_origins should be an array

CORS config allowed_origins should be an array

Issue

Laravel 7 added the fruitcake/laravel-cors package by default. However, this package was previously named barryvdh/laravel-cors. In addition, its configuration file has changed over the versions.

The combination of these may lead to some outdated code causing this error.

Solution

To resolve this error:

  1. If you are running Laravel 7 or higher, ensure you are properly including the fruitcake/laravel-cors package and update any references from Barryvdh\Cors to Fruitcake\Cors in your code. This is automated in the Laravel 7.x Shift.
  2. Verify your cors.php file is up-to-date by republishing it with artisan vendor:publish --tag="cors or comparing yours to the latest version.
  3. Clear your application cache to remove any old references by running artisan cache:clear and artisan config:clear.