Skip to content

Commit 09e4e4d

Browse files
feat: Implement configurable ALLOWED_HOSTS
This commit enhances security by replacing the wildcard `ALLOWED_HOSTS` setting with a configurable list loaded from the `DJANGO_ALLOWED_HOSTS` environment variable. - The `promo_code/settings.py` file now parses a comma-separated string from the environment variable. - The `.env.example` file has been updated to include `DJANGO_ALLOWED_HOSTS` with a default value of `localhost,127.0.0.1,0.0.0.0`.
1 parent 6456c1a commit 09e4e4d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ANTIFRAUD_INTERNAL_PORT=9090
55

66
DJANGO_DEBUG=False
77
DJANGO_SECRET_KEY=your_django_secret_key
8+
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
89

910
POSTGRES_DATABASE=your_postgres_database_name
1011
POSTGRES_HOST=db

promo_code/promo_code/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def load_bool(name, default):
2727

2828
DEBUG = load_bool('DJANGO_DEBUG', False)
2929

30-
ALLOWED_HOSTS = ['*']
30+
ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', '').split(',')
3131

3232
INSTALLED_APPS = [
3333
'django.contrib.admin',

0 commit comments

Comments
 (0)