0

I have no problems of this sort during development but after pushing to production, keep getting the error message "The page has expired due to inactivity".

I tried clearing cache and all that...

composer dump-autoload && php artisan optimize && php artisan cache:clear && php artisan config:clear && php artisan route:clear && php artisan view:clear

But it doesn't seem to help

The quick fix right now is turn off one of the application servers, but both of them running causes the page expired error. And as previously noted, this only happens in production after every push

anabeto93
  • 307
  • 3
  • 12
  • `APP_DEBUG=true` set this in your .env and check – Sapnesh Naik Dec 04 '17 at 12:49
  • 3
    Possible duplicate of ["The page has expired due to inactivity" - Laravel 5.5](https://stackoverflow.com/questions/46141705/the-page-has-expired-due-to-inactivity-laravel-5-5) – Chay22 Dec 04 '17 at 13:00
  • I just did and it is still showing the same error. But I would like to add that this usually happens after I do a git push to production. – anabeto93 Dec 04 '17 at 13:34

2 Answers2

0

Do you have the application key set in the .env file?

Try running php artisan key:generate

Also: Do you have some sort of error log from the server itself? Maybe you get more info from that.

Nieck
  • 1,626
  • 3
  • 21
  • 41
0

I also have got the Page Expired error in Laravel.

If you get a page expired ( 419 ) issue means an issue with your CSRF token.

Solution 1

If you are getting an error after submitting the form then you need to add the CSRF field to your form request.

Solution 2

If you are getting an error after calling the AJAX then you need to add a header for CSRF token using the example below.

$.ajaxSetup({
headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

Solution 3 : disable csrf protection ( Not Recommended )

Note: disable CSRF protection use only for webhooks

disable CSRF protection field for routes group or specific routes

open file VerifyCsrfToken.php on your project

dir - App\Http\Middleware\VerifyCsrfToken.php

Example Below

<?php namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
    protected $except = [
    'payment/*', // routes group
    'specific-route', // specific route
    '*', // allow all request 
   ];
}
Abdul Rehman
  • 142
  • 1
  • 12