3

为了将 cookie 发送到服务器,我必须在选项参数中使用 { 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.

奇怪的事情:当我通过浏览器调用这个 url 时没有任何错误

你可以帮帮我吗?

4

1 回答 1

0

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

于 2018-02-17T07:17:34.987 回答