Skip to content

Commit

Permalink
Force http
Browse files Browse the repository at this point in the history
  • Loading branch information
hieplpvip committed Dec 12, 2024
1 parent d122b99 commit 7802db4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions dmoj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
)

MIDDLEWARE = (
'judge.middleware.ForceHTTPMiddleware',
'judge.middleware.ShortCircuitMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand Down
9 changes: 9 additions & 0 deletions judge/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;">
<span title="{{ _('Report issue') }}">
Expand Down

0 comments on commit 7802db4

Please sign in to comment.