score:4

Accepted answer

Solution

After days of searching, I came up with a solution. Hopefully it will help someone.

All you need to do is add this two lines to php file:

header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Headers: Content-Type');

And in axios request you dont need to use headers, so it can looks like this:

axios.post("your_url", {
      your_data
    })
    .then((response) => {

    }, (error) => {

    });

Related Query

More Query from same tag