Lumen-CORS
Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework., (*1)
, (*2)
Installation
After you install lumen as per lumen docs, install lumen-cors from lumen
folder., (*3)
Run composer require "Jkirkby91-2/LumenPSR7Cors"
to install lumen-cors., (*4)
Usage
Global CORS
If you want CORS enabled for every HTTP request to your application, simply list the middleware class Jkirkby91\LumenPSR7Cors\Http\Middleware\Cors
in the $app->middleware() call of your bootstrap/app.php
file., (*5)
CORS for Routes
If you would like to enable CORS to specific routes, you should first assign the lumen-cors
middleware a short-hand key in your bootstrap/app.php
file., (*6)
$app->routeMiddleware([
'cors' => 'Jkirkby91\LumenPSR7Cors\Http\Middleware\Cors',
]);
Then, you use the key in the route options array., (*7)
$app->get('/data', ['middleware' => 'cors', function() {
//
}]);
More info. - http://lumen.laravel.com/docs/middleware#registering-middleware, (*8)
License
MIT, (*9)