diff --git a/evibes/middleware.py b/evibes/middleware.py index 7daee35e..cbf812dc 100644 --- a/evibes/middleware.py +++ b/evibes/middleware.py @@ -14,6 +14,8 @@ from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework_simplejwt.exceptions import InvalidToken from sentry_sdk import capture_exception +from evibes.settings import DEBUG + logger = logging.getLogger(__name__) @@ -70,6 +72,8 @@ class BlockInvalidHostMiddleware: allowed_hosts = getenv("ALLOWED_HOSTS").split(" ") if not hasattr(request, "META"): return BadRequest("Invalid Request") + if DEBUG: + logger.debug(f"Checking {request.META.get("HTTP_HOST")} for presence in ALLOWED_HOSTS({allowed_hosts})") if request.META.get("HTTP_HOST") not in allowed_hosts and "*" not in allowed_hosts: return HttpResponseForbidden("Invalid Host Header") return self.get_response(request)