角度:原点http://localhost在Access Control Allow Origin标头中找不到

angular : Origin http://localhost not found in Access-Control-Allow-Origin header

本文关键字:Origin 找不到 Allow Access http 原点 localhost 角度 Control      更新时间:2024-06-27

我正在使用angularjs web应用程序中的以下代码在不同的域上调用REST API,但我在控制台中看到以下错误。非常感谢您的帮助,因为这严重延误了我的交货时间。

错误:起源http://localhost在Access Control Allow Origin标头中找不到。

XMLHttpRequest:网络错误0x80070005,访问被拒绝。

代码:

$http.defaults.headers.post["Content Type"]='application/x-www-form-urlencoded';

        $http.post(this.urlBase + '/Product/PullBasket/', $httpParamSerializerJQLike(cart)).then(function success(result) {         
            if (result.status == 200) {
                Logger.info("Pull Request Id : " + result.data);
            }
            else {
                Logger.info("Error is pull request : " + result.data);
            }
        }, function failure(result) {
            Logger.fatalException("Error is pull request.");
        });

很奇怪,但似乎与https://en.wikipedia.org/wiki/Same-origin_policy

如果是这样,你就必须设置http://enable-cors.org/