在对接海康卫视WEB无插件开发包时,自己的页面连接单独的摄像头时(连接NVR没这个问题),/ISAPI/Security/sessionLogin接口会报错误:

1
2
Access Error: 400 -- Bad Request
Too many headers

提示header太多,于是我就与demo所发的请求对比,发现header多了以下(少了Authorization):

1
2
3
4
5
6
sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin

解决的办法是在nginx配置里阻止这些header:

1
2
3
4
5
6
proxy_set_header 'sec-ch-ua' "";
proxy_set_header 'sec-ch-ua-mobile' "";
proxy_set_header 'sec-ch-ua-platform:' "";
proxy_set_header 'Sec-Fetch-Dest' "";
proxy_set_header 'Sec-Fetch-Mode' "";
proxy_set_header 'Sec-Fetch-Site' "";