Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

holasoymas's avatar

419 page expired in deployment (heroku)

I deployed laravel app on heroku , but it show me 419 error , it dont show on local . I have set all the env variables like :

$ heroku config
=== writehub Config Vars

APP_ENV:               production
APP_KEY:               base64:mytoken
APP_URL:               myappurl
DB_CONNECTION:         <mysql-conn>
DB_DATABASE:           <mydb>
DB_HOST:               dbhost
DB_PASSWORD:           mypass
DB_PORT:               3306
DB_USERNAME:           c826qxe69lwelb86
JAWSDB_URL:            jawsdb_url
SESSION_DOMAIN:        <.herokuapp.com>
SESSION_DRIVER:        database
SESSION_SECURE_COOKIE: true
$ 

Is there anything i forget to put ?

I have notice something unusual , when i visit the first time on register page session is created and stored in database, but when i submit a form another session is created on database? so i am confused if it is happening because of it of different sessions or this is normal ?

I try to put add proxy if it is causing it ?

<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Illuminate\Http\Middleware\TrustProxies as Middleware;

class TrustProxies extends Middleware
{
    /**
     * The trusted proxies for this application.
     *
     * @var array|string|null
     */
    protected $proxies = '*'; // Trust all proxies (like Heroku)

    /**
     * The headers that should be used to detect proxies.
     *
     * @var int
    //  */

    protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
}

Session id is also not stored

0 likes
2 replies
ftiersch's avatar

It only happens on submitting a form? Did you include the @csrf directive into the form?

martinbean's avatar

@holasoymas Can you share the app URL, and where the error actually happens?

Sure, you‘re telling us you get a 419 error, but we have no idea what you’re doing to get that error.

Please or to participate in this conversation.