Spatie Livewire File Uploads 401 on server
Hello everyone! I'm using Filament 3.x and Spatie Media Library + docker compose.
On the local env everything is ok, but on the server I has 401 error while uploading files via upload-file?expires=1713776933&signature=6e883bc3f42d1117c5ceee6994d857a0f4df044c55f608a86619e2c0d97ad817
Googled it, but didn't find working solution. Any tips?
Solution:Jump to solution
I added
if($this->app->environment('production')) { URL::forceScheme('https'); request()->server->set('HTTPS', request()->header('X-Forwarded-Proto', 'https') == 'https' ? 'on' : 'off'); }...
if($this->app->environment('production')) { URL::forceScheme('https'); request()->server->set('HTTPS', request()->header('X-Forwarded-Proto', 'https') == 'https' ? 'on' : 'off'); }...
11 Replies
my guess permissions problems
Why there are 401 then? App didn't even reach file permissions step. No exceptions in logs
file permissions
It should be exception then
what exception? fix permissions on your file system
It should not respond 401 if the problem is connected with file permissions. If so, app would throw an exception in logs. It seems that it doesn't reach the point to upload file.
https://github.com/livewire/livewire/discussions/3084
Look this issue please
GitHub
File upload over https fails signature verification · livewire live...
Fille uploads doesn't work over https, whereas it works perfectly over http Set up livewire file upload, then use https (e.g. with ngrok) the upload fails with the request to Request URL: https...
And also it's 777 on storage folder now
then it might be some misconfiguration of your docker
But it works in local environment
Solution
I added
if($this->app->environment('production')) { URL::forceScheme('https'); request()->server->set('HTTPS', request()->header('X-Forwarded-Proto', 'https') == 'https' ? 'on' : 'off'); } to AppProvider, but now I have another issue - uploaded photos don't show - they try to get url from localhost instead of my server domain
if($this->app->environment('production')) { URL::forceScheme('https'); request()->server->set('HTTPS', request()->header('X-Forwarded-Proto', 'https') == 'https' ? 'on' : 'off'); } to AppProvider, but now I have another issue - uploaded photos don't show - they try to get url from localhost instead of my server domain
Solved: config/filesystems.php set to public and clear caches