New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem loading Livewire.js #242
Comments
#241 should fix this. |
@kennyhorna Is the latest version working for you with that fix? |
@kennyhorna Let us know if this is still an issue and we'll look into it, otherwise we think that tilkruss did a good job of fixing it. |
@kennyhorna Did you get to the bottom of this? I have the same issue. |
Can you post more info please? |
@BenSampo Does this occur with the latest version? If so, can you help us drill down to figure out the core issue? |
@lancepioch Yes it was on the latest version. I tried to put an isolated case together, as the original issue was on a client project which I can't share, but I wasn't able to reproduce it again in a different context. I'm guessing that means there's a conflict somewhere but I haven't had a chance to take a look again. The issue was as above. Followed the standard installation steps. On local (Valet) site this was working fine. As soon as I deployed it to a Digital Ocean instance (via Forge) the Livewire JS refused to load. Stranger still I was able to load the JS if I navigated to it directly, but when it was called in via a script I saw the issue as in the screenshot above (404: Aborted). |
Is there anyway you can separate the code that you can share privately? Or if you are able to take the same dependencies and recreate it in a newly generated livewire app? |
I had the same problem, in v1.0.12, again deploying to a DigitalOcean server (initially setup via Laravel Forge). I resolved it by publishing the assets:
(See also: #241) The I suspect there's something in |
I just ran into this error myself. This must have something to do with the way that my Nginx is configured (using Forge). Anyway, publishing the assets worked 👍 |
Same for me on Laravel Forge. Thanks for the tip. |
I stumbled over this problem while I installed Laravel 8 with livewire. I put "@php artisan vendor:publish --force --tag=livewire:assets" in my composer.json in the 'post-update-cmd' script. Then it worked. But it feels not like a good solution. How to do this the right way? |
I was also experiencing this problem on Laravel 7. The i changed it from |
Worked for me too... I don't know why, but seems like a bug. |
Using livewire 2.2, I have an admin panel under "app.com/admin", weird thing is local using valet works perfectly, but on production server the livewire js path is broken Edit: publishing the assets worked for me, now livewire js path is resolved to "app.com/vendor/livewire/livewire.js" |
Same here with Livewire 2.2.2, only on production server (non forge managed) with nginx. php artisan livewire:publish --assets And then adding: "@php artisan vendor:publish --force --tag=livewire:assets --ansi" at the end of the post-autoload-dump composer hook as specified by the docs > Publishing Frontend Assets. |
first step: you should run php artisan vendor:publish --force --tag=livewire:assets |
If it's a new install and you have not published your assets before, |
Solucione esto en Laravel 8 en el archivo config/livewire.php |
i use this in my config/livewire.php file & and it perfectly works for me. |
|
It's not resolving the @livewire on my production I don't know why, but on the local machine it's working fine |
Same here, after update to 2.3.17 out of the blue, 404 error on production :/ |
@RomkaLTU what version did you upgrade from? If the session was already open, maybe try just closing the browser and logging in again? Do you have your config published? If so, there might be new keys that is causing an unintentional break, can you compare the latest config with yours and see (if you have previously published)? |
I can't say exactly what from what version I upgraded, but here is my reply on another thread: #2338 (comment) |
I believe the issue has to do caching on the server. This answers elaborates on this issue https://stackoverflow.com/a/64454679/585651 In essence, the request to livewire.js never gets to PHP since it caught by webserver (nginx in my case). Hope the above provides hint/solution. Took me a while to get to this solution. |
OMG i love you ❤ |
For me i had to make sure that my js was below the livewire js import |
This works for me, but causes a error when run
|
using url( ) in config files causes error in using artisan |
I am using
|
same here any suggestions |
i tried 'asset_url' => 'http://localhost/project_name/public ' for testing environment.. |
harsh414
i tried and coment later, thanks |
this wok very well
|
|
I had the same problem, locally it works perfectly. But when taking it to the server for some reason it fails. This solved my problem, Thanks! |
|
Hello everyone ... may i join in and post a solution no one has thought of yet. I was experiencing this issue "livewire.js - 404 not found" too ... on the NGINX server. So i figured the issue is not any setting in the app - it is NGINX related. What is happening with livewire (unless the assets are published and actually existing on the server, so nginx can serve them) is that the livewire.js file is build/served by the laravel app ... this means PHP. But in the default nginx server configuration the request never gets that far, nginx just does not find the static js file and returns the 404 ... never passing the request to the laravel app. Cutting a long story short ... there is 2 solutions to fix this issue: 1.) publish the livewire.js file any any other static file, so nginx can return them. 2.) Add one line of code to the nginx config to tell nginx to check if the static file can be found on the disk/cache if not send the request to php-fpm (in our case the index.php file) so it can be build dynamically. Here is the code ... usually you may already have a directive in your nginx config that tells nginx what to do with static files ... just add this line within the directive:
So a complete directive added to the nginx server config may look like this:
if you only want this behavior for js files create a new directive and get js off the list in the previous example. Voila ... thats it and the solution to the issue that many experienced. Cheers |
This is actually a very nice way of tackling the issue. The problem is caused by Livewire's default asset_url. The fix to this issue is: Publishing the Livewire's config file and Change the default set asset_url to APP_URL. (on line 57) This will ensure that Livewire works with Production and Laravel apps hosted on XAMPP/WAMP. |
@thedanmwangi I have published the livewire but in production it give's me erreur the pathe "domainename/vendor/livewire/livewire.js" not found any help please |
The main cause of this is that Livewire is reading form the localhost's URL which is pre-defined by livewire. (Not sure why they decided to do that.)
Let me know if this solves your issue. |
thanks, it works for me.
|
thankss, its work for me in hosting, and work in laravel 9 |
First of all, sorry for taking ages to reply to all of you. I did solve the issue at the time with the custom The issue is related with Nginx, so adding an additional block to properly parse the call to the js file solved the issue. For a more detailed explanation, you can check this blog post (thanks @benjamincrozat). Pretty much:
So, right before the location block that sets your custom headers, add this one, which will prevent Nginx from interfering with this specific location: location = /livewire/livewire.js {
expires off;
try_files $uri $uri/ /index.php?$query_string;
} |
I did solve the loading js issues with this solution aswell, |
I fixed this for Livewire v3 by having my own custom route URL registered inside the AppServiceProvider@boot, which works for loading the assets and calling the update endpoint. Livewire::setScriptRoute(function ($handle) {
return Route::get('/custom/livewire/livewire-js', $handle);
}); Source: https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine |
Took me days to find this answer |
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:
This of course load the file properly as it should. Now, after I deployed the site (using Forge) it didn't load the file at all with the relative path. My network tab (Chrome) says:
I though it might be the directory/file that isn't accesible but when I hit that path adding the IP at the beginning it loads the js file just fine (http://165.227.80.80/livewire/livewire.js?)id=8456629107e9ab1c518f)
So, then checking the docs I saw that you can customized the
base_url
initializing the directive with a custom url, so I tried that also:But even with the full path the file isn't loading:
This is the link to the site.
Has anyone faced this problem before?
The text was updated successfully, but these errors were encountered: