Commit 8e19e05
committed
Fix /!/nocache and /!/csrf CSRF exemption on Laravel 13
Laravel 13 renamed the CSRF middleware from ValidateCsrfToken to
Illuminate\Foundation\Http\Middleware\PreventRequestForgery. The legacy
VerifyCsrfToken and ValidateCsrfToken classes are now @deprecated
subclasses of PreventRequestForgery.
The route exemptions here use withoutMiddleware([VerifyCsrfToken]),
and Laravel's Router::resolveMiddleware excludes via
ReflectionClass::isSubclassOf — but PreventRequestForgery is the
*parent* of the listed classes, not a subclass, so the check returns
false and the exemption is a no-op. The CSRF check fires on the
unauthenticated POST and Laravel throws TokenMismatchException, so the
client-side nocache bootstrap cannot hydrate regions under full static
caching, and /!/csrf cannot refresh the token either.
Adding PreventRequestForgery to both lists fixes Laravel 13 while
keeping the existing entries for Laravel 10-12 compatibility via the
deprecated aliases.1 parent d5fb7ed commit 8e19e05
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
0 commit comments