Angular和htaccess验证

时间:2014-03-17 15:32:53

标签: angularjs api rest authentication

在我的angularjs中,我尝试访问一个使用htacsess密码保护的远程restAPI。在这种情况下如何进行身份验证

我正在尝试以下

function ProductsCtrl ($scope,$http) {

    $http({method: 'GET', url: 'http://myuser:mypass@remoteapi_example.com'}).
    success(function(data, status, headers, config) {
    // this callback will be called asynchronously
        $scope.products = data;
         console.log('test success');
    }).
    error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
        console.log('test failed');
    });

    console.log('products');
}

但我得到了

"Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "<unknown>"]

有没有办法用angularjs处理同源策略限制?

0 个答案:

没有答案