Answer: Before RoutingMiddleware
EventManager::instance()->on('Server.buildMiddleware',
function ($event, $middleware) {
try {
$middleware->insertBefore(RoutingMiddleware::class, new CorsMiddleware());
} catch (\LogicException $exception) {
$middleware->add(new CorsMiddleware());
}
}
);
0 Comments