diff --git a/apip/middlewares/subdomain_mock.py b/apip/middlewares/subdomain_mock.py index e88d407..3ea6dce 100644 --- a/apip/middlewares/subdomain_mock.py +++ b/apip/middlewares/subdomain_mock.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.http import Http404 from rest_framework.request import Request from rest_framework.response import Response @@ -10,12 +11,15 @@ def get_request_subdomain(request: Request) -> str: host: str = request.get_host() + + print(host) + host_parts = request.get_host().split(".") if host.startswith("127.0.0.1"): return None - if len(host_parts) > 1: + if len(host_parts) > len(settings.SERVICE_HOST.split(".")): return host_parts[0] return None diff --git a/apip/settings.py b/apip/settings.py index 3c185a6..d936fa0 100644 --- a/apip/settings.py +++ b/apip/settings.py @@ -25,6 +25,8 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env.bool("DEBUG") +SERVICE_HOST = env.str("SERVICE_HOST", default="localhost") + ALLOWED_HOSTS = env.list("ALLOWED_HOSTS")