'Laravel 8 Route not Defined Error Caused by Auth Middleware

I am attempting to access a route defined in my routes/web.php file:

Route::get('/dashboard', [ConsoleController::class, 'dashboard'])->middleware('auth');

I am not logged in. The Authenticate.php middleware file attempts to redirect me back to the login page:

class Authenticate extends Middleware
{
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('');
        }
    }
}

I have also tried using return route('/'); in the Authenticate.php middleware.

My routes/web.php file has a default route which works fine if I go to the page manually:

Route::get('/', [ConsoleController::class, 'loginForm'])->middleware('guest');

However, the Authenticate.php is causing the following error:

Symfony\Component\Routing\Exception\RouteNotFoundException
Route [] not defined.
http://localhost:8888/dashboard

And it points to the following line of code:

public function route($name, $parameters = [], $absolute = true)
{
    if (! is_null($route = $this->routes->getByName($name))) {
        return $this->toRoute($route, $parameters, $absolute);
    }
    throw new RouteNotFoundException("Route [{$name}] not defined.");
}

I have found many similar posts on and off Stack Overflow, but none of those solutions have helped.

Am I naming my default route wrong? Can I not use this route in my Authenticate.php middleware? Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source