Skip to content

Commit

Permalink
Merge pull request #233 from dotkernel/issue_232
Browse files Browse the repository at this point in the history
Replace tuupola/cors with mezzio/cors.
  • Loading branch information
arhimede authored Jul 6, 2021
2 parents 2e0d507 + e4ce948 commit 030862b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 55 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
"laminas/laminas-stdlib": "^3.2",
"mezzio/mezzio": "^3.2",
"mezzio/mezzio-authorization-rbac": "^1.0",
"mezzio/mezzio-cors": "^1.0",
"mezzio/mezzio-fastroute": "^3.0",
"mezzio/mezzio-helpers": "^5.3",
"mezzio/mezzio-twigrenderer": "^2.2",
"ramsey/uuid-doctrine": "^1.6",
"roave/psr-container-doctrine": "^2.2",
"robmorgan/phinx": "^0.12",
"tuupola/cors-middleware": "^1.1"
"robmorgan/phinx": "^0.12"
},
"require-dev": {
"laminas/laminas-development-mode": "^3.2",
Expand Down
26 changes: 16 additions & 10 deletions config/autoload/cors.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

declare(strict_types=1);

use Mezzio\Cors\Configuration\ConfigurationInterface;

return [
'cors' => [
'origin' => ['*'],
'methods' => ['DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT'],
'headers.allow' => ['Accept', 'Content-Type', 'Authorization'],
'headers.expose' => [],
'credentials' => false,
'cache' => 0,
'error' => [
Frontend\App\Factory\CorsFactory::class, 'error'
]
ConfigurationInterface::CONFIGURATION_IDENTIFIER => [
'allowed_origins' => [
/**
* Leaving this line here makes your application accessible by any origin.
*
* To restrict, replace this line with a list of origins that should have access to your application.
* Example: "domain1.com", "domain2.com"
*/
ConfigurationInterface::ANY_ORIGIN
],
'allowed_headers' => ['Accept', 'Content-Type', 'Authorization'], // Custom headers
'allowed_max_age' => '600', // 10 minutes
'credentials_allowed' => true, // Allow cookies
'exposed_headers' => [], // Tell client that the API will always return this header
],
];
2 changes: 0 additions & 2 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Dot\Mail\Factory\MailOptionsAbstractFactory;
use Dot\Mail\Factory\MailServiceAbstractFactory;
use Dot\Mail\Service\MailService;
use Frontend\App\Factory\CorsFactory;
use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ErrorHandler\LogErrorHandler;
use Frontend\App\Middleware\AuthMiddleware;
Expand Down Expand Up @@ -33,7 +32,6 @@
'factories' => [
'dot-mail.options.default' => MailOptionsAbstractFactory::class,
'dot-mail.service.default' => MailServiceAbstractFactory::class,
Tuupola\Middleware\CorsMiddleware::class => CorsFactory::class,
AuthMiddleware::class => AuthMiddlewareFactory::class,
],
],
Expand Down
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

$aggregator = new ConfigAggregator([
\Laminas\HttpHandlerRunner\ConfigProvider::class,
\Laminas\Diactoros\ConfigProvider::class,
\Mezzio\Twig\ConfigProvider::class,
\Mezzio\Router\FastRouteRouter\ConfigProvider::class,
// Include cache configuration
Expand All @@ -22,6 +23,7 @@
\Mezzio\Helper\ConfigProvider::class,
\Mezzio\ConfigProvider::class,
\Mezzio\Router\ConfigProvider::class,
\Mezzio\Cors\ConfigProvider::class,

// Swoole config to overwrite some services (if installed)
class_exists(\Mezzio\Swoole\ConfigProvider::class)
Expand Down
2 changes: 1 addition & 1 deletion config/pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware;
use Mezzio\Application;
use Mezzio\Cors\Middleware\CorsMiddleware;
use Mezzio\Handler\NotFoundHandler;
use Mezzio\Helper\ServerUrlMiddleware;
use Mezzio\Helper\UrlHelperMiddleware;
Expand All @@ -15,7 +16,6 @@
use Mezzio\Router\Middleware\MethodNotAllowedMiddleware;
use Mezzio\Router\Middleware\RouteMiddleware;
use Psr\Container\ContainerInterface;
use Tuupola\Middleware\CorsMiddleware;
use Frontend\App\Middleware\TranslatorMiddleware;
use Dot\Rbac\Guard\Middleware\ForbiddenHandler;
use Dot\Rbac\Guard\Middleware\RbacGuardMiddleware;
Expand Down
40 changes: 0 additions & 40 deletions src/App/src/Factory/CorsFactory.php

This file was deleted.

0 comments on commit 030862b

Please sign in to comment.