I am new in PHP Slim Framwork. I am build an Rest API base on https://github.com/moritz-h/slim3-rest-skeleton and I have an error like this
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access "Slim"
And I fix it by using https://github.com/palanik/CorsSlim library with configure below
$settings = require __DIR__.'/settings.php';
$app = new \Slim\App($settings);
$corsOptions = array(
"origin" => "*",
"exposeHeaders" => array("Content-Type", "X-Requested-With", "X-authentication", "X-client"),
"allowMethods" => array('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS')
);
$cors = new \CorsSlim\CorsSlim($corsOptions);
$app->add($cors);
require __DIR__.'/dependencies.php';
require __DIR__.'/../app/routes.php';
It seem like I found the right library for fix it but the error still happened. Do I miss something with Slim? Any help or suggestion would be great aprreciated.