jkirkby91 / lumenpsr7cors
Requires
- psr/http-message: ^1.0
- zendframework/zend-diactoros: ^1.3
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2021-01-19 07:23:56 UTC
README
Cross-origin resource sharing (CORS) Middleware for Lumen micro-framework.
Installation
After you install lumen as per lumen docs, install lumen-cors from lumen
folder.
Install with Composer
Run composer require "Jkirkby91-2/LumenPSR7Cors"
to install lumen-cors.
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.
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.
$app->routeMiddleware([ 'cors' => 'Jkirkby91\LumenPSR7Cors\Http\Middleware\Cors', ]);
Then, you use the key in the route options array.
$app->get('/data', ['middleware' => 'cors', function() { // }]);
More info. - http://lumen.laravel.com/docs/middleware#registering-middleware