Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Is it OK to just remove fruitcake/laravel-cors while upgrading to Laravel 10?

Hello,

In the upgrade guide from version 6 to 7, it mentioned to require fruitcake/laravel-cors: https://laravel.com/docs/7.x/upgrade#cors-support

But then it causes issue when upgrading from 9 to 10, and there is no mention on it on the upgrade guide: https://laravel.com/docs/10.x/upgrade

What I did was to simply delete it from the require of composer.json and it was sucesfully updated.

There's a post related to the same issue here on the forum which I followed. But the upgrade guides don't mention anything about fruitcake/laravel-cors: https://laracasts.com/discuss/channels/laravel/upgrading-laravel-to-v10-i-got-illuminatesupport-support

Is it OK to simply do what I did and delete it from composer.json? (I assume Laravel 10 has a replacement for this package)

0 likes
4 replies
LaryAI's avatar
Level 58

Yes, it is okay to remove the fruitcake/laravel-cors package from composer.json while upgrading to Laravel 10. Laravel 10 has built-in CORS support, so there is no need for this package anymore.

However, if your application relies on the functionality provided by fruitcake/laravel-cors, you may need to find an alternative solution or implement the functionality yourself using Laravel's built-in CORS support.

To remove the package, simply delete the line "fruitcake/laravel-cors": "^2.0" from the require section of your composer.json file and run composer update.

{
    "require": {
        "php": "^8.0",
        "laravel/framework": "^10.0",
        // remove the following line
        "fruitcake/laravel-cors": "^2.0"
    },
    // ...
}
1 like
iamnehalpatel's avatar

You also need to remove following line from Http/Kernel.php file.

\Fruitcake\Cors\HandleCors::class,

4 likes
JabatoForever's avatar

U should then replace the middleware with this one is somebody has the sae issue

  protected $middleware = [
       // add this after removing the fruitcake entry
        \Illuminate\Http\Middleware\HandleCors::class,
];
1 like
dalibm's avatar

Thank you for sharing your experience with the Laravel upgrade process. It's interesting to note that the upgrade guide from version 6 to 7 recommended requiring fruitcake/laravel-cors, but there's no mention of it in the upgrade guide from version 9 to 10.

It's great that you found a solution by simply deleting it from the require section in composer.json and successfully updating to Laravel 10. Your approach seems reasonable, especially if there was no indication of a replacement for the package in the upgrade guide.

I also checked the forum post you mentioned, and it's good to see that others are discussing the same issue. However, it's indeed puzzling that the upgrade guides don't provide explicit information about fruitcake/laravel-cors.

In the absence of specific guidance in the upgrade documentation, your workaround appears to be a practical solution. However, for added assurance, you may want to keep an eye on any future Laravel announcements or updates, as there might be official information or a recommended replacement for the package.

If you encounter any unexpected issues or if Laravel 10 introduces a replacement for fruitcake /laravel-cors in the future, it would be worth revisiting the configuration to ensure compatibility with the latest practices.

2 likes

Please or to participate in this conversation.