Origin Blocked by CORS Policy Error During Sending Request with Implemented React.js with Laravel Mix

  cors, laravel, reactjs

I’m using Laravel Mix to implement React.js in Laravel. Now in one of my components, I have a form for registration, and I’m trying to send a request to my controller.
Here is the part of my code in component for handling the form submition :

 handleSubmit(e: { preventDefault: () => void; }) {
    e.preventDefault();
    axios({
        method: 'post',
        url: 'http://localhost:8080/admin/login',
        data: this.state,
    })
        .then(res => console.log(res));
}

After submitting the form I’m getting this error: enter image description here

How can I solve?

Source: Laravel

Leave a Reply