Laravel Bug Hunt Easy +10 XP
Missing CSRF in Form
POST form returns 419 error.
LaravelFind the bug
1
<form method='POST' action='/contact'>2
<input type='text' name='name'>3
<button>Submit</button>4
</form> The bug is on line 1
Select the correct fix
Show answer and explanation
Answer: Add @csrf directive inside the form
Laravel verifies CSRF tokens on POST/PUT/PATCH/DELETE requests. Add @csrf in the form to include the hidden token field.
Hint: 419 = CSRF token mismatch.
What this challenge tests
Bug Hunt in Laravel: csrf, forms, security.