Redirect loop when using multiple auth guards in Laravel 5
<p>I'm trying to set up two authentication guards: <code>internal</code> (for normal browser requests) and <code>api</code> for AJAX requests. <code>api</code> is the default guard, but I'm focusing on getting the <code>internal</code>-guard to work, for now.</p>

<p>This is my config/auth.php:</p>

<pre><code>&lt;?php

return [
    'defaults' =&gt; [
        'guard' =&gt; 'api',
        'passwords' =&gt; 'clients',
    ],

    'guards' =&gt; [
        'internal' =&gt; [
            'driver' =&gt; 'session',
            'provider' =&gt; 'users',
        ],
        'api' =&gt; [
            'driver' =&gt; 'token',
            'provider' =&gt; 'clients',
        ],
    ],

    'providers' =&gt; [
        'users' =&gt; [
            'driver' =&gt; 'eloquent',
            'model' =&gt; App\User::class,
        ],
        'clients' =&gt; [
             'driver' =&gt; 'eloquent',
             'model' =&gt; App\Client::class,
        ],
    ],

    'passwords' =&gt; [
        'users' =&gt; [
            'provider' =&gt; 'users',
            'email' =&gt; 'auth.emails.password',
            'table' =&gt; 'password_resets',
            'expire' =&gt; 60,
        ],
    ],

];
</code></pre>

<p>This is my routes.php:</p>

<pre><code>&lt;?php
Route::group([
    'domain' =&gt; 'internal.example.com',
    'middleware' =&gt; ['web', 'auth:internal']
], function () {
    Route::get('/', function () {
        return view('welcome');
    });
    Route::get('/home', 'HomeController@index');
});

Route::group([
    'domain' =&gt; 'internal.example.com',
    'middleware' =&gt; [ 'web']
], function () {
    Route::match(['get', 'post'], '/login', 'InternalAuth\InternalAuthController@login');
    Route::get('/logout', 'InternalAuth\InternalAuthController@logout');
});
</code></pre>

<p>This is InternalAuthController:</p>

<pre><code>&lt;?php

namespace App\Http\Controllers\InternalAuth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class InternalAuthController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Registration &amp; Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users, as well as the
    | authentication of existing users. By default, this controller uses
    | a simple trait to add these behaviors. Why don't you explore it?
    |
    */

    use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    /**
     * Where to redirect users after login / registration.
     *
     * @var string
     */
    protected $redirectTo = '/';

    protected $guard = 'internal';

    /**
     * Create a new authentication controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this-&gt;middleware('guest', ['except' =&gt; 'logout']);
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' =&gt; 'required|max:255',
            'email' =&gt; 'required|email|max:255|unique:users',
            'password' =&gt; 'required|confirmed|min:6',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' =&gt; $data['name'],
            'email' =&gt; $data['email'],
            'password' =&gt; bcrypt($data['password']),
        ]);
    }
}
</code></pre>

<p>Seems fine to me. But when I go to /, /home or /login in my browser, I end up in a redirect loop.
I'm missing something... Any ideas?</p>