diff --git a/src/Laravel/Middleware/Cors.php b/src/Laravel/Middleware/Cors.php index 77d09b3..8a1686f 100644 --- a/src/Laravel/Middleware/Cors.php +++ b/src/Laravel/Middleware/Cors.php @@ -98,7 +98,9 @@ protected function hasShouldRouteGroup($request): bool $middlewareGroups = collect(Route::getMiddlewareGroups())->filter(function ($group) use ($shouldClsssName, $shouldAlias) { return in_array($shouldAlias, $group) || in_array($shouldClsssName, $group); })->keys(); - $gatherMiddleware = Route::getRoutes()->match($request)->gatherMiddleware(); + $gatherMiddleware = collect(Route::getRoutes()->get())->first(function ($route) use ($request) { + return $route->uri() === $request->path(); + })->gatherMiddleware(); if (in_array($shouldClsssName, $gatherMiddleware) || in_array($shouldAlias, $gatherMiddleware)) { return true;