diff --git a/dmoj/settings.py b/dmoj/settings.py index 330b79fd5..fa5c8d710 100755 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -424,6 +424,7 @@ ) MIDDLEWARE = ( + 'judge.middleware.ForceHTTPMiddleware', 'judge.middleware.ShortCircuitMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/judge/middleware.py b/judge/middleware.py index 533ac94f8..53a152283 100644 --- a/judge/middleware.py +++ b/judge/middleware.py @@ -24,6 +24,15 @@ uwsgi = None +class ForceHTTPMiddleware: + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + request.environ['wsgi.url_scheme'] = 'http' + return self.get_response(request) + + class ShortCircuitMiddleware: def __init__(self, get_response): self.get_response = get_response diff --git a/templates/base.html b/templates/base.html index 2c67771f5..58344927b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -259,7 +259,7 @@ {% if request.resolver_match.view_name == "problem_detail" and problem %} "{{ url('new_problem_ticket', problem.code) }}" {% else %} - "/tickets/new?issue_url={{ request.build_absolute_uri()|replace('https', 'http') |urlencode }}" + "/tickets/new?issue_url={{ request.build_absolute_uri()|urlencode }}" {% endif %} style="margin-right: 5px;">