diff --git a/.env.template b/.env.template index 428212c..17626bb 100644 --- a/.env.template +++ b/.env.template @@ -15,4 +15,5 @@ POSTGRES_USER= POSTGRES_DB= DRF_SECRET_KEY= -DRF_DEBUG= \ No newline at end of file +DRF_DEBUG= +ALLOWED_HOSTS= diff --git a/mabras/settings.py b/mabras/settings.py index a002c71..6adc5ee 100644 --- a/mabras/settings.py +++ b/mabras/settings.py @@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path -import os +import os, socket # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -26,8 +26,8 @@ SECRET_KEY = os.getenv("DRF_SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv("DRF_DEBUG", False) == "True" -ALLOWED_HOSTS = [] - +ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",") +ALLOWED_HOSTS = [] if not any(ALLOWED_HOSTS) else ALLOWED_HOSTS # Application definition