Menu

Why Your Laravel Form Returns 419 Page Expired (and the One-Line Fix You're Missing)
πŸ“°

Why Your Laravel Form Returns 419 Page Expired (and the One-Line Fix You're Missing)

DEV Community: laravelΒ·Raja HunainΒ·12 days ago
#RNjcJ4s1
#devtolaravel#devto#dev#token#csrf
Long article (539 words) β€” no AI summary yet.
Reading 0:00
15s threshold

You submit a form in Laravel, and instead of a success message you get a grey screen: 419 | PAGE EXPIRED . No stack trace, no hint. Just a number.

Here is the good news: the 419 error has one cause, and one cause only. Laravel's CSRF middleware compared the token in your request with the token in your session, and they did not match β€” or the session was not there at all. Fix the token or the session, and the error is gone.

The fix that solves most cases

Every form that sends POST, PUT, PATCH or DELETE needs a CSRF token. In Blade, one directive adds it:

<form method="POST" action="/posts"> @csrf <input type="text" name="title"> <button type="submit">Save</button> </form>

Enter fullscreen mode

Exit fullscreen mode

@csrf renders a hidden _token input. Forget it, and Laravel rejects the request with a 419 before your controller ever runs.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.