Closed lucascardo12 closed 2 years ago
I made a quick test with Slim 4 and cannot reproduce. Which webserver you are running?
tuupola/cors-middleware (1.4.1)
neomerx/cors-psr7 (v2.0.2)
With Nginx I am getting the same error when origin.server
is not provided in options. Once origin.server
is provided the error goes away.
Ok if I read all the code correctly. At some point neomerx/cors-psr7
started to check for non empty server origin setting. However you can see the assertion failing only if you have zend.assertions = 1
in your php.ini
. This is why tests did not catch it either because zend.assertions = -1
is default for Fedora (my laptop) and also for GitHub actions.
Possible fix https://github.com/tuupola/cors-middleware/pull/76
Released 1.4.2 which should fix the problem.
Details Type: AssertionError Code: 1 Message: assert(false === empty($host)) File: /var/www/vendor/neomerx/cors-psr7/src/Strategies/Settings.php Line: 188 Trace
0 /var/www/vendor/neomerx/cors-psr7/src/Strategies/Settings.php(188): assert(false, 'assert(false ==...')
1 /var/www/vendor/neomerx/cors-psr7/src/Strategies/Settings.php(90): Neomerx\Cors\Strategies\Settings->setServerOrigin('https', '', 443)
2 /var/www/vendor/tuupola/cors-middleware/src/CorsMiddleware.php(230): Neomerx\Cors\Strategies\Settings->init('https', '', 443)
3 /var/www/vendor/tuupola/cors-middleware/src/CorsMiddleware.php(133): Tuupola\Middleware\CorsMiddleware->buildSettings(Object(GuzzleHttp\Psr7\ServerRequest), Object(GuzzleHttp\Psr7\Response))
4 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Tuupola\Middleware\CorsMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Slim\Routing\RouteRunner))
5 /var/www/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
6 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\ErrorMiddleware->process(Object(GuzzleHttp\Psr7\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
7 /var/www/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(GuzzleHttp\Psr7\ServerRequest))
8 /var/www/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
9 /var/www/vendor/slim/slim/Slim/App.php(199): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))
10 /var/www/public/index.php(88): Slim\App->run()
my code
$app = AppFactory::create(); $app->add(new CorsMiddleware()); ... $app->run();