Can you show the code that generates the error ?
Livewire v3 Problem - livewire/update not found
I'm a new to laravel and try to add refresh component and result is getting livewire/update not found error. Could someone help me solve the question. Thanks.
web.php
list.blade.php
' <button wire:click="$refresh"wire:confirm="Are you sure you want to refresh this page?">Refresh this component
web.php
Livewire::setScriptRoute(function ($handle) { return Route::get('/starterkit/vendor/livewire/livewire/dist/livewire.js', $handle); }); Livewire::setUpdateRoute(function ($handle) { return Route::get('/starterkit/public/vendor/livewire/update', $handle)->middleware('web'); });
Are you using wire:click="$refresh" inside your Livewire component view?
Have a look at the Livewire screencast! https://livewire.laravel.com/screencast/getting_started/installation
I tried to follow the tutorial, but the livewire.js and livewire/update still not found and I noticed that the url for the livewire.js file is including the index.php like this http://localhost/livewire/public/index.php/vendor/livewire/livewire.js?id=fcf8c2ad
but if I remove the index.php, it works. How to exclude the index.php for livewire.js?
I already add the following code in web.php, but it seems like not working
Livewire::setScriptRoute(function ($handle) { return Route::get('/livewire/public/vendor/livewire/livewire.js', $handle); }); Livewire::setUpdateRoute(function ($handle) { return Route::get('/livewire/public/vendor/livewire/update', $handle)->middleware('web'); });
looks like you installed your project wrong and now you are trying to hack Livewire update path to get around the incorrect hosting.
There is no way that /starterkit/public/vendor/livewire/update should be the path to Livewire
Your document root should be your project's public folder AND NOTHING ELSE
when I create a new laravel project with livewire and just add a button with wire:click="refresh", it still having the same error livewire.js and livewire/update is not found. How should I fix it?
@lee08 do a fresh insatll then follow the steps in the video i suggested. If it works, then do a comparison then update your codebase.
@lee08 The answer depends on how you host the site.
- Herd - default should work
- laravel serve - default should work
- MAMP/ XAAMP/WAMP - you should create a virtual server pointing to public folder
@Snapey I tried to use web.config to rewrite the url and it works but when I click the button, the 404 pop out that http://localhost:80/livewire/update is not found. I noticed that the script tag has a data-update-uri, is that the url will be called when I click on the button? Where it should be pointed to? I can't find the file in my application, did I missed something?
script src="http://localhost/app/public/vendor/livewire/livewire.js?id=fcf8c2ad" data-csrf="fbufFhj8TxilULAusFgUxA3t3SNCj3OOgyYht07Y" data-update-uri="/livewire/update" data-navigate-once="true">
@lee08 you see, this http://localhost/app/public/ is wrong...
It indicates that your web server is pointing to the project folder and not the public folder.
Fix this, reverse your hacks, and all will work well
@Snapey which means the script src should be start from public but not http://localhost?
At start, the src is http://localhost/livewire/livewire.js?id=fcf8c2ad
After I set APP_URL in .env file to http://localhost/app/public, the src become http://localhost/app/public/index.php/vendor/livewire/livewire.js?id=fcf8c2ad
After I try to rewrite url in web.config, the src become http://localhost/app/public/vendor/livewire/livewire.js?id=fcf8c2ad
web.config
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{R:1}" pattern="\.(gif|jpe?g|png)$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="public/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
Which step I did wrong? Could you please explain in detail? Thanks in advance.
Please or to participate in this conversation.