拒绝不安全的设置与头QUOT;饼干"在浏览器中的错误又请求成功 [英] Refused to set unsafe header "Cookie" error in browser yet request is successful

查看:385
本文介绍了拒绝不安全的设置与头QUOT;饼干"在浏览器中的错误又请求成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Angularjs。当我设置饼干头与 xhr.setRequestHeader()我得到在Chrome以下错误:

I'm using Angularjs. When I set Cookie header with xhr.setRequestHeader() I get the following error on Chrome:

Refused to set unsafe header "Cookie"

但是,饼干被纳入请求,并成功发送到服务器。我似乎已经配置好了一切正确的,让饼干服务器端和客户端头:

However, the Cookie is included into the request and successfully sent to server. I seem to have configured everything correctly to allow Cookie header on server and client:

有关服务器我有这些:

Header add Access-Control-Allow-Credentials "true"

客户端我指定这些:

for client I specify these:

withCredentials

这是为什么错误?

Why is this error?

推荐答案

如果你有送过来的饼干,我认为这是不够好。有跨域:真实,
        withCredentials:真
解决问题为由拒绝不安全设置标题曲奇我遇到的好。虽然警报消息仍然存在,但是,我有饼干送过来,并有正确的反应了。

if you have the cookies sent over, i think that would be good enough. Having " crossDomain: true, withCredentials: true " solved the issue of "Refused to set unsafe header "Cookie"" i encountered as well. Even though the alert message still there, however, i have the cookie sent over and have correct response back.

这篇关于拒绝不安全的设置与头QUOT;饼干"在浏览器中的错误又请求成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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