fix: enforce apex redirect using Host header
This commit is contained in:
@@ -14,7 +14,9 @@ class RedirectApexToWwwMiddleware:
|
|||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
|
||||||
def __call__(self, request: HttpRequest):
|
def __call__(self, request: HttpRequest):
|
||||||
host = (request.get_host() or "").split(":")[0].lower()
|
# Use the raw Host header so proxy-specific X-Forwarded-Host rewrites
|
||||||
|
# can't prevent the apex redirect.
|
||||||
|
host = (request.META.get("HTTP_HOST") or "").split(":")[0].lower()
|
||||||
if host == "mandelblog.com":
|
if host == "mandelblog.com":
|
||||||
destination = request.build_absolute_uri().replace(
|
destination = request.build_absolute_uri().replace(
|
||||||
"://mandelblog.com", "://www.mandelblog.com", 1
|
"://mandelblog.com", "://www.mandelblog.com", 1
|
||||||
|
|||||||
Reference in New Issue
Block a user