Selaa lähdekoodia

[libs] Apply CORS setting according to the Python version

Romain Rigaux 4 vuotta sitten
vanhempi
commit
d27f5d47c9
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      desktop/core/src/desktop/settings.py

+ 4 - 2
desktop/core/src/desktop/settings.py

@@ -362,8 +362,10 @@ if desktop.conf.CORS_ENABLED.get():
   INSTALLED_APPS.append('corsheaders')
   MIDDLEWARE.insert(0, 'corsheaders.middleware.CorsMiddleware')
   MIDDLEWARE.remove('django.middleware.csrf.CsrfViewMiddleware')
-  CORS_ALLOW_ALL_ORIGINS = True
-  CORS_ORIGIN_ALLOW_ALL = True  # Old Py2 way
+  if sys.version_info[0] > 2:
+    CORS_ALLOW_ALL_ORIGINS = True
+  else:
+    CORS_ORIGIN_ALLOW_ALL = True
 
 # Configure database
 if os.getenv('DESKTOP_DB_CONFIG'):