$ http.get Authorization Angular Error

1

Send the request as long as I do it without the header, once I put the header I get an error

getMark : function(){
            var tokenId = 'tok ' + sesionesControl.get('token');
            //tokenId me regresa el token registrado...

            var config = {
                headers : {
                    'Authorization': tokenId
                }
            };

            $http.get('http://sitio.com/app/user',config)
                .success(function(data){
                    console.log(data);
                })
                .error(function(data){
                    console.log(data);
                });
        }
  

XMLHttpRequest can not load link . Response to   preflight request does not pass access control check: No   'Access-Control-Allow-Origin' header is present on the requested   resource. Origin ' link ' is therefore not allowed access.   The response had HTTP status code 404.

OPTIONS /app/user HTTP/1.1
Host: sitio.com
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36
Access-Control-Request-Headers: authorization
Accept: */*
Referer: http://localhost/Angular/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: es-ES,es;q=0.8,en;q=0.6

Thanks to those who answer:)

P.D. When sending using apps (Chrome extensions) like PostMan if you recognize

    
asked by DarthSinuhe 11.06.2016 в 01:51
source

1 answer

1

The problem is on the server side, enabling CORS to allow you to use it.

As an extra change .succes and .error, for .then and .catch, the previous ones are already depreciated.

    
answered by 12.10.2016 в 21:57