Failed to load livewire js assets on production

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Fixing Livewire JS Asset Loading Failures in Local/LAN Environments

As a senior developer working with modern Laravel stacks, we often encounter frustrating issues when deploying applications, especially when dealing with asset bundling and serving across different environments—like a local LAN server versus a public deployment. The problem you are facing—where Livewire JS assets fail to load, specifically paths like http://10.62.230.18:81/livewire/livewire.js?id=...—is a classic symptom of an asset pipeline misconfiguration or server routing conflict.

This post will walk you through the likely causes and provide robust solutions for ensuring your Livewire assets load correctly, regardless of whether you are testing on a local machine or a production server. We will focus on leveraging Laravel’s built-in tools to ensure a smooth experience, aligning with best practices advocated by laravelcompany.com.

Understanding the Root Cause: Asset Serving vs. Routing

The issue you describe usually stems from how assets are served. When Livewire builds its assets (via Vite), they are typically outputted into the public/build directory and referenced via the @vite Blade directive. However, if the asset is being requested directly using a URL that mirrors the internal routing structure (like /livewire/livewire.js), you are essentially asking the web server to route an asset file instead of serving it from the compiled public assets folder.

In a local LAN environment, subtle differences in how Apache or Nginx handles static files versus application routes can cause these failures, particularly when dynamic query parameters (?id=...) are involved. The failure often means the web server cannot resolve the path to the actual bundled file.

Step-by-Step Solutions

Here are the most effective strategies to resolve this asset loading issue:

1. Ensure Proper Vite Compilation

Before anything else, ensure your assets are correctly compiled. Livewire relies heavily on the Vite pipeline for its JavaScript bundling.

Verify that running npm run build successfully generates the necessary files in your public directory. If you are using Laravel Breeze or Jetstream setup, this step is usually handled automatically, but manual verification is crucial, especially when testing outside a standard deployment flow.

2. Standardize Asset Loading with @vite

The most robust way to load assets in a modern Laravel application is by strictly using the @vite Blade directive within your main layout file. This directive correctly handles the asset resolution based on your vite.config.js and public path settings, abstracting away direct URL issues.

Your Layout File:
Ensure your layout remains clean and relies entirely on Vite for asset loading:

<!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>

        {{-- This single directive correctly loads all necessary CSS and JS bundles --}}
        @vite('resources/css/app.css')
    </head>
    <body>
        {{ $slot }}

        {{-- Scripts are typically handled by the main Vite entry points, not manual stacking --}}
    </body>
</html>

3. Review Environment Variables and Public Path

Your configuration variables (APP_URL, ASSET_URL) seem fine for defining the base URL, but they don't fix the underlying file serving issue. The key is ensuring your web server (Apache/Nginx) is configured to serve static files from the correct directory (usually public).

If you persist in seeing issues with dynamic paths like /livewire/livewire.js?id=..., it suggests a potential conflict where the server tries to interpret that path as a route instead of a static file request. For local development, ensure your server is pointing directly to the Laravel application root and not an intermediary proxy that might interfere with asset requests.

Conclusion

Loading Livewire assets successfully hinges on trusting the Laravel asset pipeline (Vite) rather than attempting direct manual URL access for bundled files. By standardizing your layout using @vite and ensuring your local server configuration correctly maps static assets, you eliminate most of these deployment headaches. Always prioritize using official Laravel conventions; this approach ensures that your application remains maintainable and robust, regardless of the complexity of your deployment environment.