Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Send correct CORS headers

Roland Geidera30390edb7d0
diff --git a/wger/settings_global.py b/wger/settings_global.py
index 824ef5978..3ff5d2243 100644
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -149,6 +149,7 @@ TEMPLATE_LOADERS = (
)
MIDDLEWARE_CLASSES = (
+ 'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@@ -234,6 +235,9 @@ INSTALLED_APPS = (
# Breadcrumbs
'django_bootstrap_breadcrumbs',
+
+ # CORS
+ 'corsheaders',
)
@@ -361,3 +365,8 @@ REST_FRAMEWORK = {
SOUTH_MIGRATION_MODULES = {
'easy_thumbnails': 'easy_thumbnails.south_migrations',
}
+
+
+# Set CORS policy: allow all hosts to access the API
+CORS_ORIGIN_ALLOW_ALL = True
+CORS_URLS_REGEX = r'^/api/.*$'
\ No newline at end of file