From 596d1ee7971a84e563f98ec2aa3f9c7fa777657e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 13 Apr 2017 09:43:11 +0200 Subject: [PATCH] Registered implicit options middleware --- config/autoload/middleware-pipeline.global.php | 7 ++++--- module/Rest/src/Middleware/CrossDomainMiddleware.php | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/autoload/middleware-pipeline.global.php b/config/autoload/middleware-pipeline.global.php index e07149a5..bf81f13e 100644 --- a/config/autoload/middleware-pipeline.global.php +++ b/config/autoload/middleware-pipeline.global.php @@ -4,7 +4,7 @@ use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware; use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware; use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware; use Shlinkio\Shlink\Rest\Middleware\PathVersionMiddleware; -use Zend\Expressive\Container\ApplicationFactory; +use Zend\Expressive; use Zend\Stratigility\Middleware\ErrorHandler; return [ @@ -27,7 +27,7 @@ return [ 'routing' => [ 'middleware' => [ - ApplicationFactory::ROUTING_MIDDLEWARE, + Expressive\Application::ROUTING_MIDDLEWARE, ], 'priority' => 10, ], @@ -36,6 +36,7 @@ return [ 'path' => '/rest', 'middleware' => [ CrossDomainMiddleware::class, + Expressive\Middleware\ImplicitOptionsMiddleware::class, BodyParserMiddleware::class, CheckAuthenticationMiddleware::class, ], @@ -44,7 +45,7 @@ return [ 'post-routing' => [ 'middleware' => [ - ApplicationFactory::DISPATCH_MIDDLEWARE, + Expressive\Application::DISPATCH_MIDDLEWARE, ], 'priority' => 1, ], diff --git a/module/Rest/src/Middleware/CrossDomainMiddleware.php b/module/Rest/src/Middleware/CrossDomainMiddleware.php index 0ce57e4f..4d73acbf 100644 --- a/module/Rest/src/Middleware/CrossDomainMiddleware.php +++ b/module/Rest/src/Middleware/CrossDomainMiddleware.php @@ -1,12 +1,13 @@ withHeader('Access-Control-Allow-Origin', $request->getHeader('Origin')) ->withHeader('Access-Control-Expose-Headers', 'Authorization'); - if ($request->getMethod() !== 'OPTIONS') { + if ($request->getMethod() !== self::METHOD_OPTIONS) { return $response; }