token丢失?在header传的参数null? nginx 的坑???!!!!!
在本地可以获取前端header传的参数,但是部署到服务器获取的就是null或者各种情况,如果你的服务器用了nginx做代理的话,下面应该可以帮到你
原因: nginx对header name的字符做了限制,默认 underscores_in_headers 为off,表示如果header name中包含下划线,则忽略掉,部署后就获取不到。
解决:
nginx默认忽略掉下划线可能有些原因考虑的。在header里不要用 “_” ,可以用驼峰命名或者其他的符号(如减号-)代替。在nginx里的 nginx.conf文件中配置http的部分添加 : underscores_in_headers on;(默认值是off,或者没有写这行代码)
如图: