From b01041d1502e865725f613060e33c03aa01096ca Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Thu, 5 Jun 2025 19:08:13 +0300 Subject: [PATCH] Fixes: add debugging log --- evibes/middleware.py | 4 ++++ 1 file changed, 4 insertions(+) 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)