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

Franklab's avatar

How to Resolve 409 Conflict with InertiaJS on Login Redirect in Laravel?

Hello everyone, I'm encountering a 409 Conflict error when trying to redirect a user to the dashboard after a successful login in my Laravel + InertiaJS application. I've tried several approaches, but the issue persists, and I'm looking for a clear solution to resolve this problem.

Setup Details: Backend (Laravel):

Laravel 11 InertiaJS PHP 8.4 Frontend (Vue): Using @inertiajs/inertia Vue 3

Front end:

onSubmit() { this.$refs.login.validate((valid) => { if (valid) { this.form.post(route('login'), { onFinish: () => { this.loading = false; }, onError: (errors) => { if (errors.message) { this.hasError = true; this.error = errors.message; } }, }); } }); }

From laravel:

public function login(Request $request) { $validEmail = '[email protected]'; $validPassword = 'password';

// Verify credentials
if ($request->email === $validEmail && $request->password === $validPassword) {
    
    $request->session()->regenerate();

    if ($request->header('X-Inertia')) {
        return Inertia::location(route('dashboard'));
    }

    return redirect()->route('dashboard');
}

return Inertia::render('Auth/Login', [
    'errors' => ['message' => 'Invalid credentials.'],
]);

}

What I've Tried: Using Inertia::location(route('dashboard')). Returning a redirect()->route('dashboard'). Returning JSON responses and handling redirection explicitly on the frontend using this.$inertia.visit('/dashboard'). Checked for correct headers like X-Inertia, X-Inertia-Version, and X-XSRF-TOKEN.

Question: What is the best way to handle this scenario in InertiaJS to ensure proper redirection to /dashboard after login? Am I missing something in the backend logic or the frontend configuration?

Thank you in advance for your help!

0 likes
0 replies

Please or to participate in this conversation.