Livewire: No CSRF token detected I don't know why I am getting this error Uncaught (in promise) Livewire: No CSRF token detected in my browser console.
This happens when I try to submit a form.
Laravel: 11.9
Livewire: 3.5
What is your form and componet looking like?
@jsanwo64
<div class="h-screen">
<form wire:submit="login" class="space-y-5 py-24 w-11/12 md:w-1/2 lg:w-1/4 mx-auto">
<x-form.cover for="username" label="Username" :error="$errors->first('username')">
<x-form.text
id="username"
placeholder="Username"
wire:model="username"
:error="$errors->first('username')"
/>
</x-form.cover>
<x-form.cover for="password" label="Password" :error="$errors->first('password')">
<x-form.text
show-hide
id="password"
wire:model="password"
:error="$errors->first('password')"
/>
</x-form.cover>
<div class="text-center lg:text-left">
<x-buttons.action label="Login" wire:target="login" />
</div>
</form>
</div>
Wait.... Are you creating your own login logic rather than that of Laravel?
Also, any Livewire action such as wire:click or wire:submit, you don't have to worry about CSRF, as its handled by the framework. So the form looks okay. What exactly is in your component?
You dont need to create your own Login. Laravel comes with its own Login logic. Also here
wire:submit="login"
Shows you have a component handling the login form.
I suggest you watch the livewire 3 free video course.
Please sign in or create an account to participate in this conversation.