CORS middleware for Laravel 5.5 and above
pedrosancao/laravel-cors-middleware is a Laravel package for cors middleware for laravel 5.5 and above.
It currently has 0 GitHub stars and 80 downloads on Packagist (latest version v0.1.1).
Install it with composer require pedrosancao/laravel-cors-middleware.
Discover more Laravel packages by pedrosancao
or browse all Laravel packages to compare alternatives.
Last updated
CORS middleware for Laravel 5.5 to 5.8 and 6.x.
Laravel 7 comes with fruitcake/laravel-cors, so we recommend you go with it.
This package is pretty simple, load configuration from .env and also handles
Preflight request
and custom headers.
Preferable use composer
composer require pedrosancao/laravel-cors-middleware
We use package Package Discovery so there's no need to modify any files to enable the middleware, just install and go.
Enable middleware for route:
Route::get('sample', function () {
//
})->middleware('cors');
You may configure allowed domains and headers.
First option is to set on .env: allowed domains with ALLOWED_CORS_DOMAINS having
fallback to APP_URL and allowed header with ALLOWED_CORS_HEADERS.
To add more than one domain our header separated them with comma.
To have full control of configuration you may copy the config file with:
php artisan vendor:publish --tag=cors-middlware
This library is release under the MIT licence.