404 error on any post request

Livewire did not register them. I put them in manually, and I still got the 404 error. I have since removed them.

Okay, that would suggest something went wrong with the Livewire installation. You could try removing Livewire composer remove livewire/livewire and reinstalling it composer require livewire/livewire

I ran composer remove/require and still the same 404 error. If either of you are interested, I can add you to the full private repository. Perhaps it might help to see the error duplicated locally?

I just ran a fresh Laravel install with Jetstream, Livewire…still getting this same error. Has nobody seen this before? Are there any known issues with Nginx, MacOs…anything?

Hey, @bitsalt

I don’t think this is an livewire error since you are facing the same issue after install new laravel project.

Try to deploy your project in a production/staging server and see if the error still exists or not.

I have a clean project installed on a remote server. The primary issue now, while different, also seems the same. I’m getting a 404 error because /livewire/livewire.js is not found.

What am I missing in installing this? I’m doing a jetstream install via composer with livewire as the argument.

Update: This happens when all I’ve done is installed laravel/jetstream/livewire and included the @livewireScripts and Styles tags. The “two scenarios that will cause this default behavior to break” regarding the “livewire/livewire.js” 404 error do not apply in my setup. However, after stepping through publishing the config file and front-end assets, that has taken care of the issue of the livewire.js file loading. I’m now going to create the files to test the original ‘counter’ to see if it will work.

Update 2: I ran artisan make:livewire Counter and then edited the resultant files with the code listed earlier in this thread. I then added the tag <livewire:counter /> to the default “welcome” template, so there’s nothing in this but out-of-the-box Laravel code. And now…I’m back to where I was previously, a 404 error where the request to “/livewire/message/counter” can’t be found.

@bitsalt you should update the asset_url inside
config/livewire.php
,it will update the base URL before /livewire/message/counter automatically

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

update your APP_URL inside .env file

APP_URL=your_app_url

Hi there,

I have the following problem: When I start a completely new laravel project and follow the docs, the counter example works fine. But as soon as I try to implement livewire with the counter example to an existing laravel 8 project I get an

:8000/livewire/message/counter:1 Failed to load resource: the server responded with a status of 404 (Not Found)

Is it possible that happens b/c of my fortify installation?

Any help, pleeeeeease

I just ran into the same issue.
Getting back 404 on any action, seemingly the auto-registration of the livewire/message route not working etc.

For future reference; it turned out to be my route cache :sweat_smile:
So after installing livewire in an existing project be sure to either run php artisan route:cache to re-cache or php artisan route:clear to just clear it.

Hi @Restartz i am also having exactly the same issue,mine was working before and just suddenly stopped,i tried the route:cache and route:clear but still the same issue.
Help please!!

Thanks for your suggestion. I wish I could say that worked, but no. It shouldn’t make a difference, but…I’m running an Nginx dev server locally on a Mac. I just created a new/clean project (as the one I wanted to use this on has moved on without Livewire). There’s nothing else in the way of this working, and certainly nothing in the install documentation that I’ve missed, as it seems to be quite simple.

Well this is refreshing…I got it to work running ./artisan serve, changing my APP_URL to “http://localhost” and not editing the config/livewire.php file. I’ll try pushing this to a server and see if it works there as well.

It seems there’s an issue in some combination of:

  • local Nginx dev server
  • on a Mac
  • outside temperatures too low :thinking:

Joking aside…I can deal with this locally even though I prefer my local environment to match as much as possible with production. Obviously, this will need to work with Nginx and/or Apache in a prod environment. I’ll try to follow up on that later today.

@bitsalt, I had exactly the same problem.

First of all, it worked locally. But when I move code to production I even could not reach /livewire/livewire.js. Instead I get an nginx error 404. Important - the nginx error, not from my application.

To solve problem with accessing javascript I publish Livewire assets to public. It helped but I still had issues with any call to a component. Component worked but I received a modal window with nginx 404 error.

So… The problem was with nginx configuration :slight_smile: It simply does not have a rule that looks something like this

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Instead, there was a rule that describes every url prefix that could be used in the application.

location ~ ^/(admin|assests|user|order|api|vendor){
    try_files $uri $uri/ /index.php?$query_string;
}

So, I’ve added livewire to that monstrosity regex and it works!

Finally someone with the exact same problem!

Do you have any idea, how I can configure such thing on an Apache server? Or can you suggest some keywords, to find it on my own? It looks like something, that has to be written in the htaccess file.

Regards

Sadly, last time I work with Apache and its htaccess years ago. If your problem is exactly like mine then maybe you should try to experiment with RewriteCond + RewriteRule.

As I remember, with RewriteCond you could set the regex for the url that you access and RewriteRule with transform that url to make it hit your index.php

Or even just RewriteRule could be enough. For instance, WordPress uses it to redirect to slash-appended url.
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

SOLVED (at least for me): The problem was not the .htaccess, but a setting of the apache2 config, that prevented the htaccess from being used at all.
I described the solution here: https://github.com/livewire/livewire/issues/2338#issuecomment-822557614
In short: Edit the Apache2 config, so the section Directory /var/www is set to AllowOverride All.

i had the same problem
this is how I solved it: I was getting a 404 error when publishing an update from the parent component to the child components. when a parameter was not passed to the child component