allow to disable redirect
This commit is contained in:
parent
a4a0fa4f8b
commit
6c884b7804
2 changed files with 3 additions and 3 deletions
|
@ -6,12 +6,11 @@ from urllib.parse import urlparse
|
|||
class PrimaryDomainRedirectMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
# Parse the primary hostname from WEBSITE_URL
|
||||
self.primary_host = urlparse(settings.WEBSITE_URL).netloc
|
||||
self.disable_redirect = settings.DISABLE_REDIRECT
|
||||
|
||||
def __call__(self, request):
|
||||
# Skip redirects in DEBUG mode
|
||||
if settings.DEBUG:
|
||||
if settings.DEBUG or self.disable_redirect:
|
||||
return self.get_response(request)
|
||||
|
||||
# Check if the host is different from the primary host
|
||||
|
|
|
@ -59,6 +59,7 @@ CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in HTTPS_HOSTS] + [
|
|||
|
||||
# Primary website URL
|
||||
WEBSITE_URL = env.str("WEBSITE_URL", default="https://servala.com")
|
||||
DISABLE_REDIRECT = env.bool("DISABLE_REDIRECT", default=False)
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue