Hi everyone (English is not my first language, so sorry in advance).
I trying to make a multi-language website with laravel 10 and livewire 3. I have a view with authentication and another view for guest. When I use wire:model.live in a search field, in my authentication view works perfect, I get what I searching. But when I search in the guest view, this doesn´t works, laravel redirects to my login and when I see the networks in chrome it shows "livewire/update status code 302".
Even I found here some discutions with a similar issue but I don't find the solution, cause they used livewire 2.
I don't know why is occuring this error, because one view (the guest) has guest middleware and the other has auth middleware.
this is my web.php code:
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'guest']
], function() {
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/livewire/update', $handle);
});
Route::get('/', function () {
return view('welcome');
})->name('home');
Route::get(LaravelLocalization::transRoute('routes.lots'), [GuestLotController::class, 'index'])->name('guest.lots.index');
Route::get(LaravelLocalization::transRoute('routes.lots-show'), [GuestLotController::class, 'show'])->name('guest.lots.show');
Route::get('login', [AuthenticatedSessionController::class, 'create'])
->name('login');
Route::post('login', [AuthenticatedSessionController::class, 'store']);
});
I appreciate your help. Greetings!!!
That the guest view doesn't redirect to login and make the searching to my database.
I solved my issue adding this piece of code in RouteServiceProvider.php in the boot function:
Livewire::setUpdateRoute(function ($handle) {
return Route::post('/livewire/update', $handle)
->middleware('web')
->prefix(LaravelLocalization::setLocale());
});
This works perfect in both scenarios (Guest and auth).