LaravelPackages.net
Acme Inc.
Toggle sidebar
pedrosancao/laravel-cors-middleware

CORS middleware for Laravel 5.5 and above

80
0
v0.1.1
About pedrosancao/laravel-cors-middleware

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 and 6

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.

Installation

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.

Usage

Enable middleware for route:

Route::get('sample', function () {
    //
})->middleware('cors');

Configuration

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

Licence

This library is release under the MIT licence.

Star History Chart