3

enter image description here

page expired 419 appears when in production. I've tried to run php artisan clear:cache, php artisan config:cache, php artisan key:generate, and also change the SESSION_DOMAIN with the same domain, but the page still error

if I deactivate the CSRF middleware it doesn't have an error, but I can't go to the next page.

I can run it on local, but when I use production database in local have the same error page.

  • 1
    Welcome to SO .. did read the doc ? https://inertiajs.com/csrf-protection – Kamlesh Paul Feb 26 '21 at 03:46
  • Simply add this in main blade – Ankita Dobariya Feb 26 '21 at 03:48

3 Answers3

5

i fixed it by removing this meta from the main blade.php template.

<meta name="csrf-token" content="{{ csrf_token() }}">

because of this warning on inertiajs page:

If you're using Laravel, be sure to omit the csrf-token meta tag from your project, as this will prevent the CSRF token from refreshing properly.

Peter Prieboj
  • 71
  • 1
  • 8
5

I think it is possible there are two or more issues with the 419 PAGE EXPIRED.

I was never able to get it to work by changing the CRSF token, removing it, or disabling it.

I think the actual cause has to do with permissions with where the SESSION_DRIVER data is stored.

By default the .env has SESSION_DRIVER=database. Changing database storage to file storage SESSION_DRIVER=file works if your file permissions are correct. Once you have the file permissions set correctly, change back to SESSION_DRIVER=database if you so desire.

I was using SQLite3, and the only way it worked was if the database was in location ~/laravel/stoarage/sqlite3.database

wwhite
  • 51
  • 1
  • 1
0

Using useForm instead of Inertia solved it for me.

Reference: https://laracasts.com/discuss/channels/inertia/inertiajs-vite-in-production-error-419?page=1&replyId=843186

aifodu
  • 254
  • 3
  • 2