I am using django-cors-headers to overcome cors issues in python django. But I am getting.
'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. while trying to access using angularjs from http://localhost:8000
here is my settings for CORS that I am using.
INSTALLED_APPS = INSTALLED_APPS + ['corsheaders']
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ['corsheaders.middleware.CorsMiddleware', 'corsheaders.middleware.CorsPostCsrfMiddleware']
CORS_ORIGIN_ALLOW_ALL = True
CORS_REPLACE_HTTPS_REFERER = True
CORS_ALLOW_HEADERS = (
'x-requested-with',
'content-type',
'accept',
'origin',
'authorization',
'x-csrftoken',
'accept-encoding'
)
CORS_ALLOW_METHODS = (
'GET',
'POST',
'PUT',
'PATCH',
'DELETE',
'OPTIONS'
)
if anyone has resolved this issue please let me know.
You need to do
MIDDLEWARE_CLASSES = (
...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
)
CORS_ORIGIN_ALLOW_ALL = True #for testing.
Look CorsMiddleware
is on top of CommonMiddleware
.
Hope this helps.
CORS_ORIGIN_ALLOW_ALL = False
更改允许全部为假
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.