我的Angular应用程序通过Apache在Google Chrome上运行的跨域请求,但在Firefox上失败并出现Error: a security problem occurred
错误。
以下是我的Apache
应用的Django
配置:
<Location />
Header always set Access-Control-Allow-Origin http://stage.myangularsite.com
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Credentials: true
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, authentication, accept, client-security-token"
Header always set Access-Control-Request-Headers "x-requested-with, Content-Type, origin, authentication, client-security-token"
AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/home/user/.htpasswd"
Require valid-user
</Location>
仅供参考,在接收应用中,我使用django-cors-headers
和django-rest-framework
。