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

bobwurtz's avatar

Livewire Issue Using API route

Hello!

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.

Here is my route in api.php

Route::get('/cafe/{slug}', 'Cafe\APIController@apiMenu')->name('apiMenu');

The entire purpose of this page is to view it without authentication.

Thank you!

0 likes
6 replies
Snapey's avatar

Livewire on API routes? WTF?

2 likes
martinbean's avatar
Level 80

@bobwurtz I think you need to read up on what Livewire is again, but it’s certainly not meant to be used for API routes.

furqanDev's avatar

You literally did the opposite of what Livewire was supposed to counter.

bobwurtz's avatar

Ahhhh this was a bad one. I'm an idiot... thanks guys.

abene42's avatar

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?

bobwurtz's avatar

@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.

Please or to participate in this conversation.