0

I've deployed my laravel 10 - livewire 3 apps on local server (office LAN server) but it seems the js assets of livewire did't loaded properly :

Loading failed for the with source “http://10.62.230.18:81/livewire/livewire.js?id=e2b302e9”.

This is my config file of asset url :

'url' => env('APP_URL', 'http://10.62.230.18:81'),
'asset_url' => env('ASSET_URL', 'http://10.62.230.18:81'),

This is my layout page which load the livewire's assets :

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>{{ $title ?? 'WIP' }}</title>

        @vite('resources/css/app.css')
    </head>
    <body>
        {{ $slot }}

        @stack('scripts')
    </body>
</html>

I tried solutions this solution, however it didn't work for me because there is no publishable assets for livewire:assets

How to solve this issue ?

8
  • Try to publish the Livewire assets manually. This can be done by running the following command in your Laravel project: php artisan livewire:publish --assets
    – user633440
    Commented Jan 18 at 8:56
  • @KarlHill already tried, and it says that there is no publishable resource
    – owf
    Commented Jan 18 at 9:12
  • Did you try running: php artisan config:clear?
    – user633440
    Commented Jan 18 at 9:14
  • 1
    have you also tried with the method shown in the last comment (dec 19 2023) at the link you posted?
    – suxgri
    Commented Jan 20 at 18:44
  • 1
    check this seems that something that is blocking the request.. or try add this <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> to pass.
    – francisco
    Commented Jan 23 at 9:06

2 Answers 2

0

I've run into similar issues with livewire.

When livewire assets haven't loaded for me it's usually due to a difference between a local environment and the production environment.

I've always solved it by explicitly defining the assets in the the blade layout file. In your case I would try:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>{{ $title ?? 'WIP' }}</title>

        @vite('resources/css/app.css')
        @livewireStyles
    </head>
    <body>
        {{ $slot }}

        @livewireScripts
        @stack('scripts')
    </body>
</html>

I would also suggest that you run composer update from command line after you deploy.

Also you may have cache files that were deployed unintentionally. To resolve that try removing the cache files by running

php artisan cache:clear
php artisan route:clear
php artisan view:clear

If all else fails, then it is likely a permissions issue with the /livewire/livewire.js and/or /livewire/livewire.css files. (i.e. the permissions are too strict)

Lastly, if you're building from Alpine, there are other troubleshooting options. Since I dont work with alpine the best resource I can provide is the official docs: https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine

2
0

You can try reference the livewire assests from AppServiceProvider.php

use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Livewire::setScriptRoute(function ($handle) {
            return \Route::get('/vendor/livewire/livewire.js', $handle);
        });
    }
}
1
  • 1
    already did but didn't worked for my case, i tried this github.com/livewire/livewire/issues/242#issuecomment-1862093389 and it solved the problem
    – owf
    Commented Jan 25 at 11:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.