Image upload error on production server
Upload image working fine locally but something is wrong when deploying to production server, I checked laravel log file but there were nothing, also checked the file permission and same issue
Any one can help me fix the issue ?
67 Replies
Hello, in your .env file you must change the value of APP_URL=http://127.0.0.1 to your correct domain name and make sure to execute this command:
I did that and still same issue
you need to make sure the permissions on the folder are correct too. I'm not sure what the exact settings are but you can try 655 or something similar
Did you config the
APP_URL
in .env file?It says you're getting a
401 Unauthorized
error. That means your application says you don't have permission to do what it's trying to do.Already did that
Already did that
Check the responce am getting an empty message , and it's already working locally
Can you share the code of FileUpload component? @abedrabaia
Here is the resource file
And it's working locally fine and there is no issues in Laravel log on the server
I think it's releated to Livewire upload since am not getting an error from filament , it started to happen when SSL certificate was added to the serve !
and i can't understand what causing it since it returns an empty message
i think the issue is pretty clear
its a permission issue on your production environment
i would check the server logs instead of the laravel logs
If it was a file persmession issue I would found an error in laravel log
I thing it didn't even reach the upload function !
It was rejected before and can't find why
yea thats why u should look at the server log
are you using something to manage your hosting? Plesk panel or some sort?
if your server is denying the request, you won't find it in laravel
it doesn't reach it
so no use to look tehre
@Patrick1989 We are using an Ubuntu 20 server with Apache2
I managed to upload files using native upload method but the Livewire upload is not working
and what's the log message for the 403?
or 401
should be in that file
and make sure theres not some middleware messing things up
š
oh wait
that response in your screenshot
yea nvm its coming from livewire
you sure you have no like auth middleware hanging in the middle?
Im getting same issue, nothing in logs, perms 777, works locally. Have no issue normally uploading images to this server, only until filament was implemented, and the File component
I think if it was a middleware issue it won't work locally
You found a solution yet?
and the apache log is empty?
just to make sure
Stack Overflow
Livewire WithFileUpload 401 with url's not matching so failing sign...
I have a livewire file uploader on a project. When you select a file it says The uploads failed to upload. The firefox dev toolbox says it is a 401 error. I investigated further and found via https://
See the last post. FYI most people use nginx and nice pre-built CI/CD setups for laravel
That hasnt solved it for me
in your code
do you use the preview url?
if so, does it start working when you comment it out??
Thats all I have
can you comment out this line
and see if that is the issue
these 2 files
So that uploads, but when I go to save the form:
okay but no more 401 now
No, but I cant leave the vendors edited like that?
no u canbt
but the issue is known now
not that is helps
no fix š¦
Ah š¤£ Was expecting you to know the root of all my problems š
are you using cloudflare
for ssl
or proxy
Not sure, I dont setup our servers at work š¤£
i can check
do you have an url ?
Are you able to guide me how to check? I dont think Im allowed to share the URL
Whois Lookup, Domain Availability & IP Search - DomainTools
Research domain ownership with Whois Lookup: Get ownership info, IP address history, rank, traffic, SEO & more. Find available domains & domains for sale.
yea just throw it in here
and look where the nameservers are pointing to
yea my guess is that they proxy the request
and that fucks it up, no valid signature š¦
Ah, so could be just how we have our staging servers setup rather than a constant problem?
So a valid prod URL may be fine?
sorry what do you mean exactly
So the no valid signature thing, is that not just because of our staging server? as we have many sub domains with different projects on.
Where if they then go to prod and have a proper SSL, or am I just misunderstanding things?
yea that would probably fix it
have you tried adding * to the proxies config btw
I have not, assuming thats in the nginx config? I haven't touched that, it was setup by a colleague for all projects we use
no thats in filament let me look it up for you sec
Solution
so like this
not sure if it helps but worth a try
That did actually do something, just got this error now, So it may allow the upload, but dont think its saving to the DB?
did u still have that line commented out? š
in the core file
Nah, I undone that,
It may be something to do with my code, 2 mins
hehe alright back in a few mins smoke break
Feel like I need to start with how much stress I've been getting lately š¤£
But nah, that works, the issue above was due to a check I have, in which trying to remove an avatar (I replace when upload) that didn't exist, I need to do a null check.
So is this advised or is this bad?
yea thats good
proper solution
Are you able to explain what its done? (Im just trying to learn now)
Im assuming allow anything basically
Setting trusted proxies in Laravel to * (a wildcard) solves your issue because it instructs Laravel to trust all proxies regarding the headers they set. When a Laravel application is behind a reverse proxy (like Cloudflare), certain request attributes (such as the scheme and the client IP) might be modified by the proxy.
gpt š
Fair point haha, but sometimes gpt is a bit unreliable also š¤£
So is there anything to keep an eye out that should probably be blocked but will be bypassed because of this?
if you know the exact host u can use that instead of a wildcard
but tbh i'm not expecting any issues coming from this
THats alright then, thank you š
yea we should give credit to @toeknee he pointed to the stack overflow š
Most welcomes, ideally you shouldn't use a wildcard š
Yeah, but hopefully it can be changed by something my other teams can change. Im still a junior so im clueless with this š¤£
oh dude im in the business for 15 years, i still have daily mysteries
that will never change
Yeah, raise it as a ticket upstream and they will advise accordingly š
But we are all learning daily!
Thankfully my team is only me and 2 other devs, and we all work closely, so they may know. Just they're busy currently so haven't had time to ask.
I claim just under 3 years, I did do uni for 3 years, but it wasnt all php and it was outdated, so job wise, under 3 years
But anyway, thanks guys.
your welcome!
have a nice day dudes