Laravel-Backpack / basset

Better asset helpers for Laravel apps.
MIT License
155 stars 11 forks source link

Assets are 404 File Not Found Found or wrong path in local DNS #108

Closed doncadavona closed 7 months ago

doncadavona commented 7 months ago

Issue:

The assets are not loaded correctly due to wrong paths when in local DNS: image

When I run php artisan basset, no errors are reported.

In my example recreation, I have Laravel 10 with Backpack 6 installed and served in Nginx on my local machine.

I pointed my localhost to laravel-10.local in /etc/hosts:

127.0.0.1    laravel-10.local

My Nginx properly configured to reverse-proxy this local domain to its repository in /var/www/laravel-10.

My APP_ENV is local.

When I run the app via php artisan serve, the assets are correctly loaded.

But via a reverse proxy (Nginx) in a local machine, the assets are loaded like so, which is incorrect:

http://laravel-10.local/var/www/laravel-10/vendor/backpack/theme-tabler/resources/assets/css/style.css?c540607ca732
karandatwani92 commented 7 months ago

Hey @doncadavona

Can you check APP_URL in env. It should be http://laravel-10.local in your case.

Let me know if the problem is not solved.

doncadavona commented 5 months ago

@karandatwani92 ,

Yes, my APP_URL is http://laravel-10.local. I had several Laravel installations similar to this setup since I raised this, and I encounter the same issue on all of them.

Sorry for my late reply. My regards.

doncadavona commented 5 months ago

I have resolved the issue by doing the following:

php artisan basset:clear
php artisan storage:unlink
php artisan storage:link
php artisan basset:install
sudo chown -R $USER:www-data storage
sudo chmod -R 775 storage

image

Then reloading the site in the browser.

This is perhaps caused by permissions in the filesystem and the sequence of commands are sometimes neglected but vital.

I am not sure why Basset has not thrown any errors. php artisan basset:check has no errors.