Trying to send a POST request to the server:

sendDataOnServer() { axios.post('http://localhost/parser/api/set_bet.php',{ market: this.props.bets.market, outcome: this.props.bets.type, odd: this.props.bets.odd, stake: this.state.value }) } 

But for some reason an OPTIONS request is sent, how to fix it?

    1 answer 1

    The OPTIONS method is sent by the browser to check if a cross-domain POST request is possible. And it looks like he is not allowed, so the POST request should not be.

    You can allow cross-domain requests by specifying the Access-Control-Allow-Origin: http://localhost header in the server's response Access-Control-Allow-Origin: http://localhost .

    • It worked, but I specified * instead of http://localhost . And still it was necessary to add Access-Control-Allow-Headers: * - Alexey Presman