I have such code on my php server (5.2) endpoint GET http://mydomain/get-code.php:
<?php
header("Access-Control-Allow-Origin: *");
$data = 'id=' . '123456' . '&' .
'text=' . 'some text' . '&' .
'code=' . urlencode($_GET['code']);
$ch = curl_init('https://someapi.com/login/oauth');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
preg_match('/hash=([0-9a-f]+)/', $response, $out);
echo $out[1];
curl_close($ch);
?>
I'm requesting GET http://mydomain/get-code.php from another domain.
I'm getting CORS error in browser console:
XMLHttpRequest cannot load http://mydomain/get-code.php No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9292' is therefore not allowed access.
Any ideas?
header("Access-Control-Allow-Origin: *");but this didn't help