add allowed_hosts env var

This commit is contained in:
FuzzyGrim
2023-01-27 20:52:36 +01:00
parent 07dc20b8ea
commit aaa129edf8
3 changed files with 5 additions and 9 deletions

View File

@@ -65,7 +65,7 @@ volumes:
| SECRET | String | Django secret key | Yes | None |
| TMDB_API | String | The Movie Database API key | Yes | None |
| MAL_API | String | MyAnimeList API key | Yes | None |
| ALLOWED_HOSTS | List | Base domain URL | No | None |
| ALLOWED_HOSTS | List | Base IP / Domain | Yes | None |
| PUID | Int | User ID | No | 911 |
| PGID | Int | Group ID | No | 911 |
| REGISTRATION | Bool | Enable user registration | No | True |

View File

@@ -5,9 +5,7 @@ services:
build:
context: .
environment:
- TMDB_API=API_KEY
- MAL_API=API_KEY
- SECRET=SECRET
- ALLOWED_HOSTS=192.168.1.1, yamtarr.domain.com
- PUID=1000
- PGID=1000
volumes:

View File

@@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
from decouple import config
from decouple import config, Csv
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -27,10 +27,8 @@ SECRET_KEY = config("SECRET")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)
ALLOWED_HOSTS = ["127.0.0.1"]
ALLOWED_HOSTS_ENV = os.environ.get('ALLOWED_HOSTS')
if ALLOWED_HOSTS_ENV:
ALLOWED_HOSTS.extend(ALLOWED_HOSTS_ENV.split(','))
ALLOWED_HOSTS = ["127.0.0.1"]
ALLOWED_HOSTS.extend(config('ALLOWED_HOSTS', default="", cast=Csv()))
# Application definition