Skip to content

Adds CORS (Cross-Origin Resource Sharing) headers support & CORS pre-flight OPTIONS requests for Lumen micro-framework

License

Notifications You must be signed in to change notification settings

razor9999/cors-lumen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CORS for Lumen

Latest Stable Version License

Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework.

Install with Composer

Run composer require "razor9999/cors-lumen:dev-master" to install cors-lumen.

Usage

Add CORS ServiceProvider

If you want to allow OPTIONS method then your going to need to enable the CorsServiceProvider in the bootstrap/app.php file.

$app->register('razor9999\Cors\Providers\CorsServiceProvider');

Global CORS

If you want CORS enabled for every HTTP request to your application, simply list the middleware class razor9999\Cors\Middleware\CorsMiddleware in the $app->middleware() call of your bootstrap/app.php file.

CORS for Routes

If you would like to enable CORS to specific routes, you should first assign the cors middleware a short-hand key in your bootstrap/app.php file.

$app->routeMiddleware([
	'cors' => 'razor9999\Cors\Middleware\CorsMiddleware',
]);

Then, you use the key in the route options array.

$app->get('/api/test', ['middleware' => 'cors', function() {
    //
}]);

More info. - http://lumen.laravel.com/docs/middleware#registering-middleware

Contributing

If you have a change fork it & make a pull request. :)

License

Released under the MIT, see LICENSE.

About

Adds CORS (Cross-Origin Resource Sharing) headers support & CORS pre-flight OPTIONS requests for Lumen micro-framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%