diff --git a/backend/backend/settings.py b/backend/backend/settings.py index c9a0aef..d97cefa 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -19,7 +19,6 @@ current_directory_path = os.path.dirname(os.path.abspath(__file__)) - if DJANGO_ENV == "prod": load_dotenv(os.path.join(current_directory_path, "../env/.env.prod")) else: @@ -37,6 +36,8 @@ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.getenv("SECRET_KEY") +DJANGO_ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "") + # SECURITY WARNING: don't run with debug turned on in production! DEBUG = DJANGO_ENV == "dev" @@ -52,6 +53,9 @@ "127.0.0.1", ] +if DJANGO_ALLOWED_HOSTS: + ALLOWED_HOSTS.extend(DJANGO_ALLOWED_HOSTS.split(",")) + CORS_ALLOWED_ORIGINS = [ "http://127.0.0.1:5173", "http://localhost:5173", diff --git a/backend/env/.env.dev b/backend/env/.env.dev index f5abcdf..d67a3ff 100644 --- a/backend/env/.env.dev +++ b/backend/env/.env.dev @@ -11,4 +11,5 @@ POSTGRES_USERNAME = postgres POSTGRES_PASSWORD = postgres POSTGRES_DATABASE = bwwc MONGO_HOST = mongo -MONGO_PORT = 27017 \ No newline at end of file +MONGO_PORT = 27017 +DJANGO_ALLOWED_HOSTS = "" \ No newline at end of file diff --git a/backend/env/.env.example b/backend/env/.env.example index d7e3abf..13ebfd4 100644 --- a/backend/env/.env.example +++ b/backend/env/.env.example @@ -12,4 +12,5 @@ POSTGRES_USERNAME = postgres POSTGRES_PASSWORD = postgres POSTGRES_DATABASE = bwwc MONGO_HOST = localhost -MONGO_PORT = 27017 \ No newline at end of file +MONGO_PORT = 27017 +DJANGO_ALLOWED_HOSTS = "" \ No newline at end of file