This is an old revision of the document!
Laravel
Create Project
# new project composer create-project --prefer-dist laravel/laravel PROJECT_NAME # if cloning repo you likely will need to generate a key php artisan key:generate --ansi
CORS
composer require barryvdh/laravel-cors
To allow CORS for all routes, add the HandleCors middleware in the $middleware property of app/Http/Kernel.php class:
protected $middleware = [ // ... \Barryvdh\Cors\HandleCors::class, ];
To allow CORS on a specific middleware group or route, add the HandleCors middleware to your group:
protected $middlewareGroups = [ 'web' => [ // ... ], 'api' => [ // ... \Barryvdh\Cors\HandleCors::class, ], ];
Configure CORS
php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider"