angular 4 httpGet withCredentials和header冲突

时间:2018-02-17 07:11:33

标签: angular angular4-httpclient

用于向服务器发送cookie我必须在options参数中使用{withCredentials:true},但是当我使用

    this.http.get(this.accountUrl + 'ExternalLoginConfirmation', { 
    withCredentials: true })

我收到以下错误:

    Response to preflight request doesn't pass access control check: The 
    value 
    of the 'Access-Control-Allow-Origin' header in the response must not be 
    the 
    wildcard '*' when the request's credentials mode is 'include'. Origin 
    'http://localhost:4202' is therefore not allowed access. The credentials 
    mode of requests initiated by the XMLHttpRequest is controlled by the 
    withCredentials attribute.

奇怪的是:当我通过浏览器调用此网址时,没有任何错误

你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

这是一个CORS错误, 尝试添加Cors chrome扩展浏览器并在其中添加您的网址,此错误将消失。 或永久解决 请参阅https://stackoverflow.com/a/24446980/4808975