Angular 4 HTTP自定义标头

时间:2018-04-16 14:02:24

标签: http cors http-headers

在服务中:

let headers = new HttpHeaders();
     headers = headers.append('sessionToken', token);
请求中的

{"normalizedNames":{},"lazyUpdate":[{"name":"sessionToken","value":"22ddc387-dfab-4e03-bbf9-241d75968133","op":"a"}],"headers":{},"lazyInit":{"normalizedNames":{},"lazyUpdate":null,"headers":{}}}

服务器响应:

There are no «sessiontoken» in CORS «Access-Control-Allow-Headers»

为什么不在标题中添加“sessiontoken”?

1 个答案:

答案 0 :(得分:1)

因为如错误所述,

  

CORS«Access-Control-Allow-Headers»中没有«sessiontoken»

您的服务器必须返回带标题的回复

Access-Control-Allow-Headers = "sessionToken"