I am developing a website and testing the logout functionality. The issue I'm facing is with the Navbar, which is extended across multiple components and allows users to log out of the website. The logout action works in all components except one (User.vue), where I encounter the following error:
I don't understand why the route format is incorrect in this particular case.
Below is the part of the code in the Navbar where the logout form is placed. Could you help me identify the issue?:
<form id="logout-form" action="{{ route('logout') }}" method="POST">
<input type="hidden" name="_token" :value="csrfToken">
<p onclick="document.getElementById('logout-form').submit();">Déconnexion</p>
</form>
I share also the part of web.php to show the request method to logout :
Route::post('/logout', [LogoutController::class, 'logout'])->name('logout');
Thank in Advance
You're currently putting {{ route('logout') }}
as the form route as plain text.
try binding the value :action="route('logout')
.
Or use the designated form composable. https://inertiajs.com/forms