1

I try to build an app using laravel, jetstream and inertia+vue.js

every routes work fine except logout.

the original code provided by inertia in AppLayout.vue open a modal with 404 error - but the log out works :

<form @submit.prevent="logout">
    <JetDropdownLink as="button">
        Log Out
    </JetDropdownLink>
</form>

after some researches I tried another method which gives me this error : The POST method is not supported for this route. Supported methods: GET, HEAD. Log out does not work.

<form method="post">
    <JetDropdownLink as="button" type="submit" onclick="event.preventDefault(); this.closest('form').submit();">
        Logout
    </JetDropdownLink>
</form>

I tried some kind of mashup - It stays on the same page but a question mark appears at the end of the URL : https://website.fr/app/dashboard?

<form @submit.prevent="logout">
    <JetDropdownLink as="button" onclick="event.preventDefault(); this.closest('form').submit();">
        Logout
    </JetDropdownLink>
</form>

I have no idea of where the problem could be.

in the script at the top of the AppLayout.vue :

const logout = () => {
    Inertia.post(route('logout'));
};

the route in vendor/laravel/fortify/routes :

Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
        ->name('logout');

any help will be much appreciated

1
  • can you try php artisan route:list and show the output here? or just update your question with that output Commented Apr 23, 2022 at 5:13

1 Answer 1

1

done: just had to add a route to redirect on login page after logout because logout was redirecting to / route

Route::get('/', function() {
    return redirect()->route('login');
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.