解决laravel8 报错Target class [Barryvdh\Cors\HandleCors] does not exist.

浏览1387

Illuminate\Contracts\Container\BindingResolutionException

Target class [Barryvdh\Cors\HandleCors] does not exist.

333.jpg

我们在使用laravel8框架安装barryvdh/laravel-cors扩展的时候,在app/Http/Kernel.php 的 protected $middleware 中添加\Barryvdh\Cors\HandleCors::class会报错。

解决方法就是改成在/app/Http/Kernel.php $routeMiddleware下添加

'cors' => \Barryvdh\Cors\Middleware\HandleCors::class,

image.png


  • 暂无任何回答