AngularJS拒绝设置不安全的header " cookie &;

AngularJS Refused to set unsafe header "Cookie"

本文关键字:cookie quot header 拒绝 设置 不安全 AngularJS      更新时间:2023-09-26

我正在使用AngularJS应用程序使用$http调用API。对$http的调用来自localhost:9000。API的端点在localhost:9100/API/v1.0/context…

我得到一个错误消息说"拒绝设置头Cookie"。据我所知,浏览器出于安全原因设置了这些标头,这些标头无法配置。根据这里类似的问题,我已经尝试启用crossDomain:true和withCredentials:true,但没有效果。

如果你能回答为什么会这样,我将不胜感激。

编辑:这是代码

$http({
                        method: method,
                        url: urlpoint,
                        headers:headers,
                        params: query,
                        crossDomain: true
                    })
                    .success(function(data, status, headers, config) {
                        if (!data || data.length == 0)
                            data = $rootScope.getLocaleValue("EMPTY_RESPONSE");
                        operation.result.data = data;
                        $scope._afterMakeTestCall(operation, status,
                            headers, config);
                    });

在headers字段中,我设置了

    headers['Cookie'] = 'cookieValue="something";';

经过长时间的搜索,我看到参考资料指出,由于安全漏洞,浏览器将不允许设置Cookie头。它只能通过无头浏览器完成。