I have started making the Website in Laravel 11 with MongoDB as its database but got CSRF token 419 error in Admin Login form itself.
My form Action with csrf token is as below:
<form action="{{ url('admin/login') }}" method="post">@csrf
And it is giving below 419 error:
419 PAGE EXPIRED
This is the same approach I have followed in Laravel 10 but found no issue.
The only way to get rid of this issue to add the route admin/login in app.php file like below:
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(
except: ['admin/login']
);
})
But this is not the solution and not feasible to add all routes to espace CSRF token and bypass security.