| Package Data | |
|---|---|
| Maintainer Username: | binjuhor |
| Package Create Date: | 2019-08-22 |
| Package Last Update: | 2021-12-02 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-03 15:19:02 |
| Package Statistics | |
|---|---|
| Total Downloads: | 88 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 2 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework.
After you install lumen as per lumen docs, install lumen-cors from lumen folder.
Run composer require binjuhor/lumen-cors to install lumen-cors.
If you want CORS enabled for every HTTP request to your application, head over to your bootstrap/app.php file and register your new middleware with the following lines:
$app->middleware([
Binjuhor\Lumen\Middleware\CorsMiddleware::class
]);
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.
$app->routeMiddleware([
'cors' => 'Binjuhor\Lumen\Middleware\LumenCors',
]);
Then, you use the key in the route options array.
$app->get('/api/products', ['middleware' => 'cors', function() {
//Get all products with this route
}]);
More info. - http://lumen.laravel.com/docs/middleware#registering-middleware