I am having CORS
issue with PHP. I have following code in my angular:
$http({
url: url,
method: "GET",
headers: {
'Authorization': 'Bearer zPwDlSp5AKv7MnZRwWyULhavD3WmTFPH',
'Content-Type': 'application/json'
},
data: JSON.stringify({'user_id': '17'})
}).then(function(response) {
console.log('Success!');
console.log(response.data);
}, function(response) {
console.log('Failed!');
console.log(response);
})
And following php code in backend:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Accept, Origin");
header('Access-Control-Allow-Credentials: true');
However, headers are set correctly I got:-
preflight request error.