When I try to upload a file on the production server the upload goes to 100% and then says error uploading. If I check the browser console it shows the upload failed because of a 401 error.
I’m running Laravel 11, Livewire 3, and Filament 3
I thought this may have been a signed url issue as the requests are going through Cloudflare, so I turned off Cloudflare proxying (also to verify Cloudflare’s auto-minification wasn’t messing anything up) – no change. I set the following in bootstrap/app.php – no change.
->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: ['*']);
})
finally I commented out the check for a signed url in Livewire’s src file just to be sure this was not the issue
vendor/livewire/livewire/src/Features/SupportFileUploads/FileUploadController.php
//abort_unless(request()->hasValidSignature(), 401);
What else could be causing this issue?
2
Answers
I'm not sure the actual cause but I had it running on Laravel Octane with FrankenPhp. As soon as I disabled that the problem went away. I'll try to investiagte and post the actual cause of the issue when I have a bit more time.
In my case my app is available from two different domains. Removing
hasValidSignature
creates security hole. The files/livewire/upload-file.js
and/livewire/preview-file.js
can now be forged.You can create your own signature validation and rewrite it in
register()
method ofAppServiceProvider