Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rretzko's avatar
Level 15

Livewire 404 Error

Hi all - Just starting to figure out Livewire on a vanilla Laravel 8 install and am hitting a 404 error on the dashboard from the @livewire('navigation-menu').

I've updated by .env file

APP_URL=http://localhost/dev/qkAdminPnl/todos/

and my config/livewire.php

'asset_url' => env('APP_URL', 'http://localhost'),

and have included the @LivewireStyles and @LivewireScripts in the app.blade.php file

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

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">


        @livewireStyles

        <!-- Scripts -->
        <script src="{{ asset('js/app.js') }}" defer></script>

        <!-- Alpine.js -->
         <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>

    </head>
    <body class="font-sans antialiased">
        <x-jet-banner />

        <div class="min-h-screen bg-gray-100">
            @livewire('navigation-menu')

            <!-- Page Heading -->
            @if (isset($header))
                <header class="bg-white shadow">
                    <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                        {{ $header }}
                    </div>
                </header>
            @endif

            <!-- Page Content -->
            <main>
                @if(session()->has('message'))
                    <div class="w-full bg-green-100 text-green-900 text-center">
                        {{ session()->get('message') }}
                    </div>
                @endif

                <!-- custom errors -->
                @if(session()->has('errs'))
                    <div class="w-full bg-red-100 text-red-900 text-center">
                        {{ session()->get('errs') }}
                    </div>
                @endif

                {{ $slot }}
            </main>
        </div>

        @stack('modals')

        @livewireScripts
    </body>
</html>

I must still be missing something, but not seeing it. All help is appreciated! Thanks - Rick

0 likes
7 replies
Rretzko's avatar
Level 15

UPDATE: changed the livewire.php to

'asset_url' => url('/') 

from

'asset_url' => env('APP_URL', 'http://localhost/dev/qkAdminPnl/todos'), 

and that resolved the 404 error. NOTE: 'asset_url' noted originally is incorrect, the above is the correct value.) Still, any thoughts on why one works and the other doesn't or what this setting is looking for, are appreciated!

Rretzko's avatar
Level 15

FURTHER UPDATE: with 'asset_url' => url('/'), the 404 error are cleared, but command line directive:

php artisan make:model Projects

fails with the following:

  Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in C:\xampp\htdocs\dev\qkAdminPnl\todos\vendor\laravel\framework\src\  
  Illuminate\Routing\RoutingServiceProvider.php on line 65  

Resetting the value to:

'asset_url' => env('APP_URL')

then succeeds. I'm guessing this is a relative-path issue, but your advice is appreciated!

Rretzko's avatar
Rretzko
OP
Best Answer
Level 15

Resolved this by launching through laravel server (php artisan serve) rather than calling it directly from localhost.

1 like
Tromp's avatar

On my UI, I have a list of items and a delete button implemented via a form. Something I've done many times without issue, but now I have one that just doesn't want to work no matter what I've tried. It just doesn't like this particular route for some reason.. I just get a 404.

I've tried clearing the cache, the route cache, reoptimyzing, composer dump-autoload, The route can be seen if I do a route:list https://www.myloweslife.run/

Rretzko's avatar
Level 15

Seeing the code would be helpful. Look for: Spelling errors, differences between dashes and underscores, differences between upper- and lower-case duplicate routes position of routes in web.php Good luck!

mkwsra's avatar

Just the following code to your admin or control panel routes:

use Livewire\Controllers\HttpConnectionHandler;

Route::post('livewire/message/{name}', [HttpConnectionHandler::class, '__invoke']);

And remember to override the url using this one linear:

<script>
    window.livewire_app_url = '{{route('admin.index')}}';
</script>

More detailed answer could be found here

https://stackoverflow.com/questions/69553897/laravel-livewire-how-to-customize-the-global-message-url

Please or to participate in this conversation.