1

I set up my Laravel 8+ application on Heroku.com. Almost everything works perfectly, but when I try to register/login I got the "419 | Page Expired" error. I am new in Laravel, but here is some information, which I think is important:

  • @csrf is in all the forms, and the head contains <meta name="csrf-token" content="{{ csrf_token() }}">
  • I tried php artisan cache:clear command, and I tried register/login in another browsers as well
  • other forms work perfectly
  • in my localhost register/login works
  • here is the settings what I use in the Heroku site:

heroku settings

As I said I am new in Laravel, and I have no idea what did I wrong. I sent a ticket to Heroku, which is in progress, but I do not think so, that they can help me.

Osanda Gamage
  • 446
  • 2
  • 6
  • 16
  • Does this answer https://stackoverflow.com/questions/52583886/post-request-in-laravel-error-419-sorry-your-session-419-your-page-has-exp#:~:text=The%20Session%20Expired%20or%20419,should%20be%20fine%20as%20well. ? – OMi Shah Feb 07 '22 at 12:13

1 Answers1

0

I was able to solve this problem by disabling csrf token verification for my login/registration paths. In the file App\Http\Middleware\VerifyCsrfToken.php

class VerifyCsrfToken extends Middleware
{
     protected $except = [
         'payment/*', // exclude all URLs with payment/ prefix
         'user/add' // exclude exact URL
     ];
}

After doing this I no longer got the 419 error or that the page expired. This article helped me solve my problem https://karoldabrowski.com/blog/solution-for-419-page-expired-error-in-laravel/