laravel 解决跨域问题及新laravel包加载更新

1.在框架下目录(laravel\app\Http\Kernel.php)下添加

protected $middleware = [

\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,

\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,

\App\Http\Middleware\TrimStrings::class,

\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,

\App\Http\Middleware\TrustProxies::class,

\Barryvdh\Cors\HandleCors::class,

];

'api' => [

'throttle:60,1',

'bindings',

\Barryvdh\Cors\HandleCors::class,

],

2.执行命令

composer require barryvdh/laravel-cors;

3.发布命令

php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider"

4.laravel 依赖包执行命令

composer config -g repo.packagist composer https://packagist.laravel-china.org

你可能感兴趣的:(laravel)