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

tangtrongnghia's avatar

I can't install fruitcake/laravel-cors on Laravel 11

Laravel 11

I am encountering an issue when using dd() to debug an API call from the client side, resulting in the error "No 'Access-Control-Allow-Origin' header is present on the requested resource."

I tried to fix it by using fruitcake/laravel-cors to solve the problem, but unfortunately, I continue to have issues installing fruitcake/laravel-cors on Laravel 11.

composer require fruitcake/laravel-cors
./composer.json has been updated
Running composer update fruitcake/laravel-cors
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - fruitcake/laravel-cors[v0.1, ..., v0.1.2] require illuminate/support 4.x -> found illuminate/support[v4.0.0, ..., v4.2.17] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.2.0, ..., v0.2.3] require illuminate/support ~4.1 -> found illuminate/support[v4.1.0, ..., v4.2.17] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.3.0, ..., v0.4.0] require illuminate/support 5.0.x -> found illuminate/support[v5.0.0, ..., v5.0.33] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.5.0 requires illuminate/support ~5.0.17|5.1.x -> found illuminate/support[v5.0.22, ..., v5.1.41] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.6.0 requires illuminate/support 5.0.x|5.1.x -> found illuminate/support[v5.0.0, ..., v5.1.41] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.7.0, ..., v0.7.2] require illuminate/support ~5.0.14|5.1.x -> found illuminate/support[v5.0.22, ..., v5.1.41] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.7.3 requires illuminate/support ~5.0.14|5.1.x|5.2.x -> found illuminate/support[v5.0.22, ..., v5.2.45] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.8.0 requires illuminate/support 5.1.x|5.2.x -> found illuminate/support[v5.1.1, ..., v5.2.45] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.8.1, ..., v0.8.2] require illuminate/support 5.1.x|5.2.x|5.3.x -> found illuminate/support[v5.1.1, ..., v5.3.23] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.8.3, ..., v0.9.2] require illuminate/support 5.1.x|5.2.x|5.3.x|5.4.x -> found illuminate/support[v5.1.1, ..., v5.4.36] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.9.3, ..., v0.10.1] require illuminate/support 5.3.x|5.4.x|5.5.x -> found illuminate/support[v5.3.0, ..., v5.5.44] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.11.0 requires illuminate/support 5.3.x|5.4.x|5.5.x|5.6.x -> found illuminate/support[v5.3.0, ..., v5.6.39] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.11.1 requires laravel/framework 5.5.x|5.6.x|5.7.x -> found laravel/framework[v5.5.0, ..., v5.7.29] but it conflicts with your root composer.json require (^11.0).
    - fruitcake/laravel-cors v0.11.2 requires illuminate/support 5.5.x|5.6.x|5.7.x -> found illuminate/support[v5.5.0, ..., v5.7.28] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v0.11.3 requires illuminate/support 5.5.x|5.6.x|5.7.x|5.8.x -> found illuminate/support[v5.5.0, ..., v5.8.36] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v0.11.4, v1.0.0] require illuminate/support ^5.5|^6 -> found illuminate/support[v5.5.0, ..., v5.8.36, v6.0.0, ..., v6.20.44] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v1.0.1, ..., v1.0.2] require php ^7.1.3 -> your php version (8.3.7) does not satisfy that requirement.
    - fruitcake/laravel-cors v1.0.3 requires illuminate/support ^5.5|^6.0|^7.0 -> found illuminate/support[v5.5.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v1.0.4, ..., v1.0.6] require illuminate/support ^5.5|^6.0|^7.0|^8.0 -> found illuminate/support[v5.5.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v2.0.0, ..., v2.0.1] require illuminate/support ^5.6|^6.0|^7.0|^8.0 -> found illuminate/support[v5.6.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors v2.0.2 requires illuminate/support ^6|^7|^8 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - fruitcake/laravel-cors[v2.0.3, ..., v2.2.0, v3.0.0] require illuminate/support ^6|^7|^8|^9 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16] but these were not loaded, likely because it conflicts with another require.
    - Root composer.json requires fruitcake/laravel-cors * -> satisfiable by fruitcake/laravel-cors[v0.1, ..., v0.11.4, v1.0.0, ..., v1.0.6, v2.0.0, ..., v2.2.0, v3.0.0].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require fruitcake/laravel-cors:*" to figure out if any version is installable, or "composer require fruitcake/laravel-cors:^2.1" if you know which you need.

Please help me resolve this issue or suggest an alternative solution. Thank you.

0 likes
5 replies
JussiMannisto's avatar

You don't need that package anymore. CORS support is built in. You can run the command below to publish the cors.php config file:

php artisan config:publish cors
3 likes
tangtrongnghia's avatar

@JussiMannisto I've tried, but it still doesn't solve the problem when I use the dd() function to debug.

login:1 Access to XMLHttpRequest at 'api.order.local/api/login' from origin 'order.local:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
wblondel's avatar

@tangtrongnghia Well, publishing the configuration file won't change anything. You need to modify it to your likings.

Could you post your existing CORS configuration file?

tangtrongnghia's avatar

@wblondel

'paths' => ['api/*', 'sanctum/csrf-cookie'],

'allowed_methods' => ['*'],

'allowed_origins' => ['*'],

'allowed_origins_patterns' => [],

'allowed_headers' => ['*'],

'exposed_headers' => [],

'max_age' => 0,

'supports_credentials' => true,

Please or to participate in this conversation.