The API I am trying to access has disabled CORS so I need to request on the server side. Utilizing React and Axios I am making a get request to the local php file which should execute cURL but am just getting the php code back instead of it executing
<?php $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.darksky.net/forecast/myAPIKet/coords");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl)
echo $result;
return;
?>
<script>
let info = axios.get('./proxy.php')
console.log(info.data);
</script>
When this runs just the php code is logged in my console instead of the php script triggering and echoing the data I want.