I am running into an issue trying to use Livewire on a Laravel API route. Triggering a Livewire request using the standard wire:model syntax, the login page is returned (I can see it in the JS error in the console and it is also the subsequent network request). Has anyone experienced this before? Why is it trying to ask for authentication? According to the Livewire docs, middleware from the original request is applied to all Livewire requests on that page.
My case is similar but it is not an API. I am using livewire to show a page that doesn't required authentication. I don't use any route in the page that has auth middleware but when a livewire request is sent the login page keeps on returning. Can anyone help me on how I could disable auth for livewire just for this request?
@abene42 Can you share the relevant route from your web.php file? Are you running the request through a controller before returning the view? Maybe there is an auth check in there? From the Livewire docs:
The second security measure Livewire puts in place is "persistent middleware". This means Livewire will capture any authentication/authorization middleware that was used during the "Initial Request" and re-apply it to subsequent requests.
My issue was fixed once I stopped using an API route and used a normal route. It works without authentication.