通过 request.META.get(“HTTP_***”)是正常情况下,获取header的方式,但是一上线(apache下),就无法政策获取header,找了半天,发现***apache会拦截authorization字段***,这个太难想到了。解决方案是在apache设置中,设置允许authorization。如下
<VirtualHost *:*> ServerAdmin 10.50.132.176 ServerName 10.50.132.176 ErrorLog F:\wamp\bin\apache\apache2.4.37\logs\error_django.log CustomLog F:\wamp\bin\apache\apache2.4.37\logs\access_django.log common DocumentRoot "*" WSGIScriptAlias / * ***WSGIPassAuthorization On*** <Directory *> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost>
django生产环境下获取headers失败(authorization被apache拦截)
最新推荐文章于 2023-09-28 17:56:18 发布