Angularjs $http响应返回整个index.html

Angularjs $http响应返回整个index.html,angularjs,xmlhttprequest,angularjs-http,Angularjs,Xmlhttprequest,Angularjs Http,我有site.com。 每个请求都重定向到此处,以便“site.com/book”、“site.com/settings”ecc。。指向“site.com” 然后我有site.com/api/其中的'site.com/api/user','site.com/api/library/'ecc。。。被重定向 我试图使用AngularJS的$http向site.com/api请求一个JSON对象。 成功后,我收到状态200,但响应为“site.com/index.html”的text/html 随请求

我有site.com。 每个请求都重定向到此处,以便“site.com/book”、“site.com/settings”ecc。。指向“site.com” 然后我有site.com/api/其中的'site.com/api/user','site.com/api/library/'ecc。。。被重定向

我试图使用AngularJS的$http向site.com/api请求一个JSON对象。 成功后,我收到状态200,但响应为“site.com/index.html”的text/html

随请求一起发送的标头包括: 接受:application/json、text/plain、/ 内容类型:application/json;字符集=utf-8

我尝试用app postman调试site.com/api/,由于我收到了正确的JSON对象,所以它可以正常工作

我不知道这是否是某个.htaccess规则或AngularJS的$routeProvider的问题。。。 我在“site.com”中有一个.htaccess文件,在“site.com/api”中有另一个。 但我可能完全偏离了道路。也许有人能帮忙?谢谢

var config = {method: 'POST', url: 'site.com/api/', data: $scope.data};
$scope.login = function(){
    $http(config)
    .success(function(resp, status, headers, config){
        console.log(resp);
    })
    .error(function(resp, status, headers, config){
        console.log(status);
    });
};

好吧,今天早上我又试了一次,头脑清醒了。 我似乎缺少url site.com/api/的http部分

因此,它可以与这两者一起工作

var config = {method: 'POST', url: 'http://example.com/api/', data: $scope.data};


请张贴代码的角度部分,或者删除角度标签
var config = {method: 'POST', url: '/api/', data: $scope.data};