Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bufferoverflow's avatar

Missing required parameters but i'm passing them with a middleware

The routes file defines the routes for my users subdomain, so I need to pass the {subdomain} variable to every route. I made a simple middleware to achieve this:

    public function handle($request, Closure $next)
    {
        URL::defaults([
            'subdomain' => $request->subdomain
        ]);

        return $next($request);
    }

The problem is that when i add the Auth routes to the file, the missing parameter error appears:

Auth::routes(['verify' => true]); // Error missing parameter for route 'login'

If i print the php artisan route:list, the middleware is also applied to the auth routes. Why is it still complaining?

0 likes
2 replies
jlrdw's avatar

Have you tried

$request->user()->subdomain

But maybe this doesn't work passing to a sub domain.

Have you tried to lookup subdomains:

site:laracasts.com subdomain
or
site:laracasts.com pass parameter to subdomain
or
site:laracasts.com multi tenant

etc

Above is for a Google search.

bufferoverflow's avatar
bufferoverflow
OP
Best Answer
Level 7

Thanks for answering.

I did a bit more of research and I'm posting the solution for anyone with the same problem.

Basically, the error was with the Authenticate.php middleware. Just change this:

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

// To this (where $request->domain is what you set in your routes as '{domain}'):
class Authenticate extends Middleware
{
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('login', [
                'domain' => $request->domain
            ]);
        }
    }
}

Please or to participate in this conversation.