Currently I'm using Laravel Breeze integrated with Next.js but when I use the email verification function it's fine until I click on the verify link in the email it responds with this error:
The GET method is not supported for route login. Supported methods: POST.
But when I log in successfully, it still hasn't verified my email I tried adding a get method with the following path:
public function getLoginInfo()
{
$message = urlencode('Please log in to verify your email.');
$redirectUrl = "http://localhost:3000/login?message=$message";
Log::debug('Verification URL: not verified');
echo "<script>
setTimeout(function() {
alert('Please login and click once again on the email address link you provided during registration to verify your email.');
window.location.href = '$redirectUrl';
}, 3000); // 5 seconds delay
</script>";
exit();
}
This is my verification controller email:
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(
config('app.frontend_url').RouteServiceProvider::HOME.'?verified=1'
);
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(
config('app.frontend_url').RouteServiceProvider::HOME.'?verified=1'
);
}