Rest Api slim3 php7 Apache2 mysql mongo-replica
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1.0 KiB

<?php
// Application middleware
// e.g: $app->add(new \Slim\Csrf\Guard);
// This is the middleware
// It will add the Access-Control-Allow-Methods header to every request
$app->add(new \Tuupola\Middleware\CorsMiddleware([
"origin" => ["*"],
"methods" => ["GET", "POST", "PUT", "PATCH", "DELETE"],
"headers.allow" => ["Access-Control-Allow-Origin", "Authorization", "Content-Type","Accept"],
"headers.expose" => [],
"credentials" => false,
"cache" => 0,
"error" => function ($request, $response, $arguments) {
$data["status"] = "error";
$data["message"] = $arguments["message"];
return $response
->withHeader("Content-Type", "application/json")
->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
},
]));
/*
$app->add(new Tuupola\Middleware\CorsMiddleware([
"origin" => ["*"],
"methods" => ["GET", "POST", "PUT", "PATCH", "DELETE"],
"headers.allow" => [],
"headers.expose" => [],
"credentials" => false,
"cache" => 0,
]));
*/