Assets Not Found Using Laravel/Livewire

Weirdest thing… and I cant seem to figure it out…would love some assistance!

I’m using Laravel/Livewire… and a “framework” built on top of Livewire, which is called filament.
Docs

Everything is working fine locally, and I’ve also had this app deployed on a server outside of Cleavr and it worked fine… so I’m guessing that this has something to do with the symlinking that Cleavr sets during deployment.

The issue is:
when I hit the url of my /login page, I’m getting 404 not found errors for the assets that filament requires…which are being served from a vendor controller that Filament provides. Here is the controller logic:
AssetController
The vendor route definition:
routes/web.php

And my dev tools:

The strange part is, if I copy and paste the exact link (im getting a 404 from) into my browser, then hit that same exact url, the file/content pops right up:

  • I’ve tried using npm run dev, npm run production… neither worked.
  • I’ve cleared out every artisan option there is
  • I’ve turned off by browser caching
  • I’ve turned off cloudflare caching
  • I tried publishing my vendor assets (and subsequently copying them into my root storage folder)

… ??

been at this for hours… no clue… thanks in advance guys

Hey @jhavens-tech, welcome to the Cleavr forum!

I do recall a very similar issue we received via our support channel. It seemed to be related to this issue https://github.com/livewire/livewire/issues/2266 though I never heard back if this resolved the issue they were having or not.

We’ll take a look at this further and see if we can figure out what the issue might be.

thank you for the welcome, really enjoying Cleavr… it has all the combined features that many of the others have some of but are missing other parts of. So thank you for the great product ! And once I heard you guys were coming out with v2, I was sold! :grinning:
There’s always these little kinks to work out.

I did come across that github issue in my troubleshooting and, though that thread is pretty anti-climactic, I managed to get the livewire.js assets to work, which I believe was when I ran the vendor:publish command.

The filament assets are the ones that are still puzzling me …since they’re working when I visit the url directly but not working when being called from application’s context

I’m wondering… do you think it could be an nginx thing? I’m a real amateur when it comes to nginx… but since this app worked on another server (that didnt use the symlinks that Cleavr uses), I’m trying to think of what would be different in that sense…

This thread also seems possibly helpful with the issue being asset_url set to null. https://github.com/livewire/livewire/issues/242#issuecomment-762444004

similar thread - https://laracasts.com/discuss/channels/livewire/livewire-404-error

I’ve tried messing with the asset_url a bit but ultimately it’s Filament that’s not complying with the conventions of the framework, as mentioned in this github thread

Since they’re using absolute url’s within their package, I’m pretty sure this is where the root of problem lies… I’m just stumped as to whats different on a cleavr server that would produce this 404…yet, continue to serve the file when hitting the asset url directly.

One more thing to look at on the server is the nginx error log - this might let you know if it’s running across an issue with the assets directory - SSH into server and nginx logs can be viewed with cat /var/log/nginx/error.log.

https://laravel-livewire.com/docs/2.x/installation > Configuring the Asset Base Url

Maybe this describes what’s going on? Do you think updating the assets location to /admin/assets will help?

If you can checkout the nginx error logs (need to ssh first and then run something like tail -f /var/log/nginx/error.log and refresh the page. It might give you some insights on what it is trying to load.

ooookkk!

So, i tried the asset_url adjustment and that still didnt work for the Filament assets but you mentioned the Nginx log, so I checked that out and saw that it was logging errors for the path that it was looking for. I then copied the Filament assets directly to the path that was logged in the Nginx logs and BAM! its working!!

So in this particular edge case (because Filament is not complying with the conventions and isnt affected by the usual approaches), I am just going to make a couple custom flow steps which copy these assets during deployment.

Thank you so much sir, couldnt have done it without you! :+1: :+1:

2 Likes

That’s awesome!

I think we’ll need to give NGINX error logs a more prominent position within Cleavr. We only make them available right now when NGINX fails - but this is a good use-case to make them available either way.

Also, please continue posting updates here if you have any handy suggestion for working with Livewire / Filament - I’m sure others will appreciate the tips. :slight_smile:

That’d be great, especially with Nginx dummies like myself (one of more prevalent reasons that I use sites like Cleavr to host these apps).

Definitely, this had me beating my head against the wall .

Here’s the resulting hook for those in need:

php artisan vendor:publish --tag="filament-assets"

mkdir /home/my-user/my-app/current/public/admin/assets/

cp -r /home/my-user/my-app/storage/app/public/vendor/filament/css/ /home/my-user/my-app/current/public/admin/assets/

cp -r /home/my-user/my-app/storage/app/public/vendor/filament/js/ /home/my-user/my-app/current/public/admin/assets/

Thanks again guys!

2 Likes

Thanks for sharing. Linking the folders might be better than copying the assets (at least in terms of performance and storage)

Adding this link as another possible solution for this Filament issue: Unreachable assets · Discussion #460 · filamentphp/filament · GitHub

1 Like

The solution for this issue is to configure nginx so so that he sends your asset requests to PHP if he did not find the file

1 Like