laravel cors "Class cors does not exist"错误

标签 laravel laravel-5 cors

我已关注https://github.com/barryvdh/laravel-cors在我的应用程序上启用 CORS。

当我刷新页面(REST 端点)时,我收到以下消息:-

Class cors does not exist

我运行了以下命令:-

composer require barryvdh/laravel-cors 0.7.x

并在我的composer.json中有以下行

"barryvdh/laravel-cors": "0.7.x"

路由.php

Route::group(['middleware' => 'cors'], function($router){
    $router->get('names/{id}', 'NameController@showEmpDetail');
    $router->resource('names', 'NameController');
});

我猜测在某个地方我需要调用该包,例如使用该包等......但我没有找到任何结果来帮助我。

请帮忙。

谢谢

最佳答案

尝试添加

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

 /app/Http/Kernel.php $routeMiddleware

关于laravel cors "Class cors does not exist"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33078340/

相关文章:

iframe - iframe 中的自动高度内容(CORS?)

php - Laravel 4 中的事务和事件

javascript - 使用地理编码器的 Laravel 表单请求

Spring Security CORS 不适用于 Http PUT 方法

html - Amazon S3 图像,无法使用 html5 Canvas 保存,出现 Tainted Canvases 错误

mysql - laravel 5 Eloquent 左连接

javascript - vue.js 和 laravel 使用 vuetify 进行简单表单提交

javascript - 将多个下拉选项保存在一个数组中

php - "no-ansi"选项不存在

laravel-5 - 删除 Laravel 5 中排队的作业