laravel 解決跨域問題及新laravel包載入更新
阿新 • • 發佈:2018-12-19
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 依賴包執行命令