I've installed Fortify locally and implemented the login routes as well as 2FA without any issues (i.e. users can login, enable it, scan the QR code, input a code to confirm and after that it will always ask for a 2FA code when logging in). However, after deploying it on Heroku, I was getting a 404 when hitting /login. If I run php artisan route:list I could still see all of Fortify's routes. Weird. So I decided to move them to routes\web.php and add Fortify::ignoreRoutes(); to the register method in FortifyServiceProvider.php. It worked. But after trying to log in I got this error:
Target [Illuminate\Contracts\Auth\StatefulGuard] is not instantiable while building [Laravel\Fortify\Http\Controllers\AuthenticatedSessionController].
I then also added this to the register method in FortifyServiceProvider.php :
$this->app->bind(StatefulGuard::class, function () {
return Auth::guard(config('fortify.guard', null));
});
This fixed the previous problem, the user was logged in, but I still got this error:
Target [Laravel\Fortify\Contracts\LoginResponse] is not instantiable.
And when I tried to enable 2FA I got this error:
Target [Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider] is not instantiable.
This is as far as I got. I'm sure there must be a "hack" to prevent this error but this can't be the proper way to fix it. I followed the official instructions and got it to work locally so obviously the different environment is the key factor. I just can't think of anything that could cause this. Some extra configuration in Heroku I'm missing, perhaps?
Thank you to anyone who can help me with this!