如何处理CORS超过$ HTTP在Angularjs1.3 [英] how to handling CORS over $http in Angularjs1.3

查看:154
本文介绍了如何处理CORS超过$ HTTP在Angularjs1.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何在Angularjs 1.3跨域访问的过来吗?
我曾尝试以下,但它似乎不能正常工作。
问题是,有没有从Angularjs关于这个问题的一篇文章。

Does anyone know how to come over cross-domain-access on Angularjs 1.3? I have tried following, but it seems not working properly. The problem is there is no a single article from Angularjs regarding this issue.

app.config([
    "$httpProvider",
    function($httpProvider){
        $httpProvider.defaults.headers.common['Access-Control-Allow-Headers'] = '*';
    }
]);

感谢。

推荐答案

这不是一个客户端的变化。您需要其中API是更新服务器,并添加页眉访问控制允许来源允许一个Cors请求:

It's not a client side change. You need to update the server where the api is and add a header Access-Control-Allow-Origin to allow Cors requests:

Access-Control-Allow-Origin: *

这篇关于如何处理CORS超过$ HTTP在Angularjs1.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆