This error occurs because Laravel is trying to resolve a container binding or middleware named role, but no such class or alias is registered.
In Laravel 12, middleware aliases must be explicitly registered in bootstrap/app.php.
If you are using role (e.g. middleware('role:admin')), make sure the middleware alias is defined (e.g. from Spatie Laravel Permission) or remove/rename it.
Fix:
Register the middleware alias or use the fully qualified middleware class, then clear the cache:
php artisan optimize:clear
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.