express.js应用程序中的响应标头

时间:2015-07-11 13:16:33

标签: node.js express

我在我的快递应用程序中设置响应标头如下:

app.use(function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET', 'PUT', 'POST', 'DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
  next();
});

然而,当服务器发送响应时,它们如下所示:

Response headers
0:A
1:c
10:t
11:r
12:o
13:l
14:-
15:A
16:l
17:l
18:o
19:w
2:c
20:-
21:M
22:e
23:t
24:h
25:o
26:d
27:s
3:e
4:s
5:s
6:-
7:C
8:o
9:n
Accept-Ranges:bytes
Access-Control-Allow-Headers:Content-Type, Authorization
Access-Control-Allow-Origin:*

有任何线索如何解决?

1 个答案:

答案 0 :(得分:0)

更改自:

res.header('Access-Control-Allow-Methods', 'GET', 'PUT', 'POST', 'DELETE');

res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE');