Enable CORS
This commit is contained in:
parent
700faf4351
commit
30849019af
@ -8,6 +8,10 @@ class Api
|
|||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
Response::response()->header("Cache-control: no-cache");
|
Response::response()
|
||||||
|
->header("Cache-control: no-cache")
|
||||||
|
->header("Access-Control-Allow-Origin: *")
|
||||||
|
->header("Access-Control-Allow-Methods: *")
|
||||||
|
->header("Access-Control-Allow-Headers: *");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,14 @@ SimpleRouter::error(function (Request $request, Exception $exception) {
|
|||||||
Response::response()->httpCode(is_int($code) ? $code : 500)->json(["message" => $exception->getMessage()]);
|
Response::response()->httpCode(is_int($code) ? $code : 500)->json(["message" => $exception->getMessage()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// CORS
|
||||||
|
SimpleRouter::options('/', function () {
|
||||||
|
Response::response()
|
||||||
|
->header("Access-Control-Allow-Origin: *")
|
||||||
|
->header("Access-Control-Allow-Methods: *")
|
||||||
|
->header("Access-Control-Allow-Headers: *");
|
||||||
|
})->setMatch('/(.+)/is');
|
||||||
|
|
||||||
// Index
|
// Index
|
||||||
SimpleRouter::all("/", function () {
|
SimpleRouter::all("/", function () {
|
||||||
Response::redirect("docs", 301);
|
Response::redirect("docs", 301);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user