我正在开发一个应用程序,其中前端是使用AngularJS API制作的,它向使用Django Rest Framework开发的后端API发送请求。
The frontend is on the domain: https://front.bluemix.net
And my backend is on the domain: https://back.bluemix.net
我在前端API向后端API发出请求时遇到了问题。错误信息如下:
Error: CSRF Failed: Referer checking failed - https://front.bluemix.net does not match any trusted origins.
我正在使用CORS,已经在Django后端API的settings.py中包含了以下代码:
ALLOWED_HOSTS = []
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CSRF_TRUSTED_ORIGINS = ['https://front.bluemix.net/']
CORS_REPLACE_HTTPS_REFERER = True
CSRF_COOKIE_DOMAIN = 'bluemix.net'
CORS_ORIGIN_WHITELIST = (
'https://front.bluemix.net/',
'front.bluemix.net',
'bluemix.net',
)
有人知道如何解决这个问题吗?