Back to Error Center

Route [login] not defined

Error Message

Route [login] not defined

Cause

The auth middleware is trying to redirect to a named route 'login' that doesn't exist. Authentication scaffolding hasn't been installed.

Solution

Install authentication scaffolding with Breeze or Jetstream. Define a login route manually. Configure the login redirect in config/auth.php.

Code Example

Fix
# Install Breeze for authentication scaffolding
composer require laravel/breeze --dev
php artisan breeze:install blade
npm install && npm run build
php artisan migrate

# Or manually define the route
Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/login', [LoginController::class, 'login']);

Debugging Steps

  1. Check if auth scaffolding is installed
  2. Run php artisan route:list --name=login
  3. Check the auth middleware redirect config
  4. Install Breeze or Jetstream if needed

Prevention

Install authentication scaffolding early in development. Define all required named routes. Test authentication flow after setup.