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

rassem_bs's avatar

Redirection issue for request submitted with Laravel Precognition

I'm using Laravel Precognition using vue and inertia for live validation, after submitting form redirection does not happen:

import {useForm} from "laravel-precognition-vue";

const form = useForm('post', route('super-admin.invite.setPassword'), {
  inviteToken:props.token,
  name: props.user.name,
  lastName: props.user.last_name,
  email: props.user.email,
  password : null,
  password_confirmation : null
});

const submit = () => form.submit();

This controller action:

    public function SetSuperAdminPassword(UpdateSuperAdminDTO $superAdminData)
    {
        $user = User::where('invite_token', $superAdminData->inviteToken)->firstOrFail();
        $superAdminData->setInviteTokenToNull();
        $user->update($superAdminData->all());
			
		// I have tried these different syntaxes
		//return to_route('dashboard')
		//return Inertia::location(route('dashboard'));
        return redirect()->route('dashboard');
    }

when looking on Network tap in Browser devtool request was succeed with 200 and response type is: text/html;

0 likes
3 replies
rassem_bs's avatar

@gych So should I make redirection from the front end after the request succeeds? something like this:

import {useForm} from "laravel-precognition-vue";
import {router} from "@inertiajs/vue3";

const form = useForm('post', route('super-admin.invite.setPassword'), {
  inviteToken:props.token,
  name: props.user.name,
  lastName: props.user.last_name,
  email: props.user.email,
  password : null,
  password_confirmation : null
});

const submit = () => form.submit({
    onSuccess: () => {
      router.get('/login');
    }
  });
gych's avatar

@rassem_bs Yes that's one possible solution but I advise you to test the precognition inertia package first and see if it works with that package without adding the redirect to the front end.

Please or to participate in this conversation.