Back to Error Center
Method not allowed (CSRF token)
Error Message
The POST method is not supported for route /login. Supported methods: GET, HEAD.
Cause
The route only accepts GET but the form is submitting with POST, or vice versa. The route definition doesn't match the form's HTTP method.
Solution
Check the route definition for the correct HTTP method. Ensure the form action and method are correct. Check for route registration order conflicts.
Code Example
Fix
// Route definition
Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
Route::post('/login', [AuthController::class, 'login']);
// Form
<form action="{{ route('login') }}" method="POST">
@csrf
<input type="email" name="email">
<input type="password" name="password">
<button type="submit">Login</button>
</form>
Debugging Steps
- Run php artisan route:list to check HTTP methods
- Verify the form method attribute
- Check for route conflicts or overrides
- Ensure both GET and POST routes are defined
Prevention
Use Route::resource() for consistent route definitions. Always include matching GET and POST routes for forms. Test form submissions.