Good morning staff
I'm making an application with angular and cakePHP. I'm trying to make a request for the backend and the following message appears in the console:
XMLHttpRequest can not load link . In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access.
My controller
.controller('loginCtrl', ['$scope', '$stateParams', '$http', '$location', function ($scope, $stateParams, $http, $location) {
$scope.fazerLogin = function(usuario){
//console.log(usuario);
//http://localhost:8765/api/v1/users/client.json?client_id=cliente&client_secret=segredo"
var url = "";
var cid = "cliente";
var cs = "segredo";
$http.post("http://localhost:8765/api/v1/users/client.json?client_id="+cid+"&client_secret="+cs).success(function(data){
console.log(data);
});
}
}])
My php
<?php
public function beforeFilter()
{
parent::beforeFilter();
$this->response->header('Access-Control-Allow-Origin','*');
$this->response->header('Access-Control-Allow-Methods','*');
$this->response->header('Access-Control-Allow-Headers','X-Requested-With');
$this->response->header('Access-Control-Allow-Headers','Content-Type, x-xsrf-token');
$this->response->header('Access-Control-Max-Age','172800');
}
?>
Where do I have to make the adjustment in my php?