Attempt to send an axios post request over a react app to laravel api returns 419 status

980 Views Asked by At

I'm trying to send an email with a contact form on my React.js app that send a post request to the laravel api server, but upon trying to actually send the request, I get the error 419 (CSRF token missing) but since it's an api I can't actually get the cookie as i could in laravel view folder. Any ideas?

export const csrf = "http://localhost:8000/api/v1/contact"
 const data = {
                name: name,
                subject: subject,
                email: email,
                message: message,
            }
axios.post(contactUrl, data).then((response) => console.log(response));

This is the react app part

    Route::post('/contact', [ContactController::class, 'send'])
        ->name('send-mail');

And this is my route defined in Api.php

0

There are 0 best solutions below