zrnik / php-slim-cors
Slim Framework 4 CORS
Installs: 1 438
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires (Dev)
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-03-12 08:56:25 UTC
README
I just wanted to remove CORS error from my React
application to my Slim Framework 4 API.
Installation
composer require zrnik/php-slim-cors
Requires Slim Framework 4 & PHP 8.1+
Usage
Add this middleware to your \Slim\App
:
$app = new \Slim\App(); $app->add(new \Zrnik\SlimCors\CorsMiddleware());
That's it. There are optional parameters for the CorsMiddleware
object:
$app = new \Slim\App(); $app->add( new \Zrnik\SlimCors\CorsMiddleware( allowedOrigins: [ 'my-frontend.app', 'another-app.com', ], allowedMethods: [ 'GET', 'POST' ] ) );