Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch 419 errors after logging in #1189

Open
robdekort opened this issue Jun 26, 2024 · 2 comments
Open

Catch 419 errors after logging in #1189

robdekort opened this issue Jun 26, 2024 · 2 comments

Comments

@robdekort
Copy link

There have been quite a few reports on Discord over the last weeks that on non expired browser windows, Laravel apps show the 419 error page after logging in. A retry fixes the issue. The 419 error page is not a pretty sight for clients. I feel it would be better if users would be redirected back to the login screen and get a retry warning there instead.

@jasonvarga
Copy link
Member

You can do this already in your own apps for now in bootstrap/app.php (for Laravel 11)

return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions) {
+        $exceptions->render(function (\Symfony\Component\HttpKernel\Exception\HttpException $e) {
+            if ($e->getStatusCode() === 419) {
+                return redirect('/wherever-you-want-them-to-go');
+            }
+        });
    })->create();

@robdekort
Copy link
Author

Nice, thanks @jasonvarga!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants