Livewire.js 404 when app is hosted in sub directory

My application is in "app" sub directory https://example.com/app, filament admin is showing login page but livewire.js is not found. Console shows https://example.com/livewire/livewire.js not found. How can I make it work? All other assets like filament.css, app.css, app.js loading without any issues.
10 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Darpan
DarpanOP2y ago
I did that but it still shows error unless I change the app url in .env to https://example.com/app/public. Is there any way to hide public from url?
Dennis Koch
Dennis Koch2y ago
Check your APP_URL. Is it https://example.com/app?
Dennis Koch
Dennis Koch2y ago
GitHub
Problem loading Livewire.js · Issue #242 · livewire/livewire
It's likely to be a simple thing but I can't manage to solve it on my own smh. On my local env it's working fine just doing this: ... @livewireAssets </body> This of course load t...
Darpan
DarpanOP2y ago
Yes, app url is https://example.com/app but when I change it to https://example.com/app/public it works.
Dennis Koch
Dennis Koch2y ago
That doesn't sound right.
awcodes
awcodes2y ago
Sounds like your server config isn't right. /app should be serving /app/public otherwise you are risking exposing the whole app publicly.
Dan Harrin
Dan Harrin2y ago
you should visit https://example.com/app/.env and become frightened
laraveldev04523
laraveldev0452310mo ago
Not sure exactly what your configuration is, however I am running Filament v3.2.35, which upgraded Livewire to v3.4.6 from v3.3.5 and in doing so, I had a similar issue where livewire/livewire.js did not load when APP_DEBUG=false, which is what you would set it to in a production environment naturally. I found the issue to be in the https://github.com/livewire/livewire/blob/7e7d638183b34fb61621455891869f5abfd55a82/src/Mechanisms/FrontendAssets/FrontendAssets.php file that was recently updated. In my Filament service provider, I updated my configuration for Livewire in the boot method: (this is because my Filament app runs under an alias defined in Apache.) Livewire::setScriptRoute(function ($handle) { return config('app.debug') ? Route::get('/alias-goes-here/livewire/livewire.js', $handle) : Route::get('/alias-goes-here/livewire/livewire.min.js', $handle); }); So, this matches the change to Livewire and now my app works just as it did before! Hope this helps!
GitHub
livewire/src/Mechanisms/FrontendAssets/FrontendAssets.php at 7e7d63...
A full-stack framework for Laravel that takes the pain out of building dynamic UIs. - livewire/livewire
Bryan Useche (KaiserF50)
If you use NGINX as Web server, there are a little change do you have to do: in your vhost file, just delete the js word, below of your server configuration, an that's it, at least worked on it for me
Want results from more Discord servers?
Add your server