# HG changeset patch # User ymh # Date 1423958206 -3600 # Node ID bb1d902e0f63214f95426a5d285188a4ca1d4311 # Parent 7148746cb47aa96500af6d4e77abf09aaed7037c add cors headers to api diff -r 7148746cb47a -r bb1d902e0f63 src/ldtplatform/settings.py --- a/src/ldtplatform/settings.py Fri Jan 30 15:34:34 2015 +0100 +++ b/src/ldtplatform/settings.py Sun Feb 15 00:56:46 2015 +0100 @@ -80,6 +80,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', 'django.middleware.gzip.GZipMiddleware', @@ -129,6 +130,7 @@ 'django.contrib.admin', 'django.contrib.staticfiles', 'haystack', + 'corsheaders', 'tastypie', 'guardian', 'taggit', @@ -249,6 +251,9 @@ } HAYSTACK_SIGNAL_PROCESSOR = 'ldt.indexation.signals.LdtSignalProcessor' +#Cors headers for API +CORS_ORIGIN_ALLOW_ALL = True + from config import * if not "SRC_BASE_URL" in locals(): @@ -275,6 +280,9 @@ if not "MEDIA_URL" in locals(): MEDIA_URL = BASE_URL + 'static/media/' +if not "CORS_URLS_REGEX" in locals(): + CORS_URLS_REGEX = r"^" + BASE_URL + 'ldtplatform/api/.*$' + #forced settings MAX_TAG_LENGTH = 255 FORCE_LOWERCASE_TAGS = True diff -r 7148746cb47a -r bb1d902e0f63 virtualenv/res/lib/lib_create_env.py --- a/virtualenv/res/lib/lib_create_env.py Fri Jan 30 15:34:34 2015 +0100 +++ b/virtualenv/res/lib/lib_create_env.py Sun Feb 15 00:56:46 2015 +0100 @@ -47,6 +47,7 @@ 'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'DEFUSEDXML' : {'setup':'defusedxml', 'url':'https://pypi.python.org/packages/source/d/defusedxml/defusedxml-0.4.1.tar.gz', 'local': 'defusedxml-0.4.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'https://github.com/toastdriven/django-tastypie/archive/v0.9.15.tar.gz', 'local': 'django-tastypie-0.9.15.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-CORS-HEADERS' : {'setup':'django-cors-headers', 'url':'https://github.com/ottoyiu/django-cors-headers/archive/1.0.0.tar.gz', 'local': 'django-cors-headers-1.0.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, 'DJANGO-CHUNCKED-UPLOADS' : {'setup': 'django-chuncked-uploads', 'url':'https://github.com/IRI-Research/django-chunked-uploads/archive/v0.5.tar.gz', 'local':'django-chunked-uploads-0.5.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, } diff -r 7148746cb47a -r bb1d902e0f63 virtualenv/res/src/django-cors-headers-1.0.0.tar.gz Binary file virtualenv/res/src/django-cors-headers-1.0.0.tar.gz has changed diff -r 7148746cb47a -r bb1d902e0f63 virtualenv/web/res/res_create_env.py --- a/virtualenv/web/res/res_create_env.py Fri Jan 30 15:34:34 2015 +0100 +++ b/virtualenv/web/res/res_create_env.py Sun Feb 15 00:56:46 2015 +0100 @@ -37,6 +37,7 @@ 'PYTHON-DIGEST', 'DEFUSEDXML', 'DJANGO-TASTYPIE', + 'DJANGO-CORS-HEADERS', 'DJANGO-CHUNCKED-UPLOADS', ]