© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•11mo ago•
3 replies
Yuka さん

Persistent 419 CSRF Error on Livewire File Uploads behind Cloudflare Tunnel

Hey everyone,

I'm running into a frustrating
419 CSRF token mismatch
419 CSRF token mismatch
error, but only when uploading files via Livewire components. Regular Livewire component updates (POST requests to
/livewire/update
/livewire/update
) work perfectly fine.


The Problem:

* When a user tries to upload a file using a Filament/Livewire
FileUpload
FileUpload
component, the POST request to
https://sub.domain.com/livewire/upload-file?...
https://sub.domain.com/livewire/upload-file?...
fails with a 419 error.
* Looking at the network response for the 419, the server is trying to
Set-Cookie
Set-Cookie
for a new session, indicating it didn't recognize the original session for that specific upload request.
* The
X-CSRF-TOKEN
X-CSRF-TOKEN
header is being correctly sent with the failing upload request (matching the token from the initial page load meta tag).
* Regular Livewire actions/updates on the same page work without any CSRF issues.

What I've Tried So Far:
1. Trusted Proxies: Configured using
monicahq/laravel-cloudflare
monicahq/laravel-cloudflare
and replaced the default
TrustProxies
TrustProxies
in
bootstrap/app.php
bootstrap/app.php
as per their docs.
2. .env Configuration:
*
APP_URL={The Domain From Cloudflared}
APP_URL={The Domain From Cloudflared}

*
SESSION_DOMAIN=.domain.com
SESSION_DOMAIN=.domain.com
(also tried
null
null
and
sub.domain.com
sub.domain.com
)
*
SESSION_SECURE_COOKIE=true
SESSION_SECURE_COOKIE=true

3.
config/session.php
config/session.php
:
Checked
same_site
same_site
(currently
'lax'
'lax'
, also tried
'none'
'none'
with
secure=true
secure=true
).
http_only
http_only
is
true
true
.
4. Livewire Upload Middleware: Tried adding
'web'
'web'
and just
StartSession::class
StartSession::class
to
temporary_file_upload.middleware
temporary_file_upload.middleware
in
config/livewire.php
config/livewire.php
. No change.

My Suspicion:
Has anyone encountered a similar issue with Livewire file uploads behind Cloudflare Tunnels or other reverse proxies where only the upload route loses the session? Any ideas on what else to check (specific Cloudflare settings, Livewire internals, PHP session handling nuances)?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Spatie Livewire File Uploads 401 on server
FilamentFFilament / ❓┊help
2y ago
419 CSRF Error on Livewire after migrating from Laravel 9 + Filament 2 to Laravel 11 + Filament 3
FilamentFFilament / ❓┊help
4mo ago
Intermittently 419 error
FilamentFFilament / ❓┊help
3y ago
S3 File Uploads
FilamentFFilament / ❓┊help
3y ago