From a7f69e8b6f6426a538d0580292eaa0370aedf4bc Mon Sep 17 00:00:00 2001 From: Julien Verhaeghe Date: Thu, 1 Jun 2017 15:17:57 +0200 Subject: [PATCH] New way of testing the method of the request --- src/Routing/Middleware/CorsMiddleware.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routing/Middleware/CorsMiddleware.php b/src/Routing/Middleware/CorsMiddleware.php index c29b87a..e6da60b 100644 --- a/src/Routing/Middleware/CorsMiddleware.php +++ b/src/Routing/Middleware/CorsMiddleware.php @@ -18,7 +18,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res ->withHeader('Access-Control-Allow-Credentials', $this->_allowCredentials()) ->withHeader('Access-Control-Max-Age', $this->_maxAge()); - if ($request->is('options')) { + if (strtoupper($request->getMethod()) === 'OPTIONS') { $response = $response ->withHeader('Access-Control-Allow-Headers', $this->_allowHeaders($request)) ->withHeader('Access-Control-Allow-Methods', $this->_allowMethods())