Support the ongoing development of →
Laravel Session Vue.js

It seems that the issue you're facing is related to using Inertia.js with Laravel. In Inertia.js, you cannot return a traditional redirect response from your controller. Instead, you should use Inertia's native methods to handle redirection.

Update your authenticateAgency method to return an Inertia response:

use Inertia\Inertia;

public function authenticateAgency(Request $request)
    if (Auth::guard('agency')->attempt($request->only('email', 'password'))) {
        return Inertia::location(route('agencyHome'));
    } else {
        return Inertia::render('YourLoginFormComponent', [
            'error' => 'You are not authorized to access this resource',

Replace YourLoginFormComponent with the name of your Vue.js login form component.

In your Vue.js login form component, make sure to handle and display the error message:

  <!-- Your form markup -->
  <div v-if="error">{{ error }}</div>

export default {
  props: {
    error: String,
  // rest of your component code

By using Inertia's native methods, you should be able to handle redirection and display error messages in your Laravel + Inertia.js application.


Sign in to participate in this thread!


Your banner here too?

baha bahacherni Joined 11 Apr 2023


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.