From 603958349798cea8913403561c67109340ab9367 Mon Sep 17 00:00:00 2001 From: Michael Darko Date: Mon, 15 Nov 2021 08:57:33 +0000 Subject: [PATCH] :sparkles: added cors config --- config/cors.php | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 2 +- 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 config/cors.php diff --git a/config/cors.php b/config/cors.php new file mode 100644 index 0000000..f976c37 --- /dev/null +++ b/config/cors.php @@ -0,0 +1,114 @@ + "*", + + /* + |-------------------------------------------------------------------------- + | Configure allowed HTTP methods + |-------------------------------------------------------------------------- + | + | Configures the Access-Control-Allow-Methods CORS header. + | Expects a comma-delimited string (ex: 'GET,PUT,POST') or + | an array (ex: ['GET', 'PUT', 'POST']) + | + */ + "methods" => "GET,HEAD,PUT,PATCH,POST,DELETE", + + /* + |-------------------------------------------------------------------------- + | Configure allowed HTTP headers + |-------------------------------------------------------------------------- + | + | Configures the Access-Control-Allow-Headers CORS header. Expects a + | comma-delimited string (ex: 'Content-Type,Authorization') or + | an array (ex: ['Content-Type', 'Authorization']). If not specified, + | defaults to reflecting the headers specified in the request's + | Access-Control-Request-Headers header. + | + */ + "allowedHeaders" => "*", + + /* + |-------------------------------------------------------------------------- + | Configure expose headers + |-------------------------------------------------------------------------- + | + | Configures the Access-Control-Expose-Headers CORS header. Expects + | a comma-delimited string (ex: 'Content-Range,X-Content-Range') + | or an array (ex: ['Content-Range', 'X-Content-Range']). + | If not specified, no custom headers are exposed. + | + */ + "exposedHeaders" => "", + + /* + |-------------------------------------------------------------------------- + | Configure credentials + |-------------------------------------------------------------------------- + | + | Configures the Access-Control-Allow-Credentials CORS header. + | Set to true to pass the header, otherwise it is omitted. + | + */ + "credentials" => false, + + /* + |-------------------------------------------------------------------------- + | Configure max age + |-------------------------------------------------------------------------- + | + | Configures the Access-Control-Max-Age CORS header. Set to + | an integer to pass the header, otherwise it is omitted. + | + */ + "maxAge" => null, + + /* + |-------------------------------------------------------------------------- + | Configure preflight continue + |-------------------------------------------------------------------------- + | + | Pass the CORS preflight response to the next handler. + | + */ + "preflightContinue" => false, + + /* + |-------------------------------------------------------------------------- + | Log open + |-------------------------------------------------------------------------- + | + | Provides a status code to use for successful OPTIONS requests, + | since some legacy browsers (IE11, various SmartTVs) choke on 204. + | + */ + "optionsSuccessStatus" => 204, +]; diff --git a/index.php b/index.php index 53f838e..ffab84a 100644 --- a/index.php +++ b/index.php @@ -80,7 +80,7 @@ | CORS errors at you. | */ -app()->cors(); +app()->cors(CorsConfig()); /* |--------------------------------------------------------------------------