Skip to content

Commit b106821

Browse files
Try to fix redirects
1 parent 8dc76af commit b106821

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

homu/server.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,12 @@ def redirect_to_canonical_host():
10221022
request_url = urllib.parse.urlparse(request.url)
10231023
redirect_url = request_url
10241024

1025+
# Assume that we're always deployed behind something that hides https:// from us.
1026+
# In production TLS is terminated at ELB, so the actual bors app sees only http:// requests.
1027+
request_url = redirect_url._replace(
1028+
scheme="https"
1029+
)
1030+
10251031
# Disable redirects on the health check endpoint.
10261032
if request_url.path == "/health":
10271033
return
@@ -1042,9 +1048,8 @@ def redirect_to_canonical_host():
10421048
elif redirect_url.path == "/" + prefix:
10431049
redirect_url = redirect_url._replace(path="/")
10441050

1045-
print("request_url=", request_url)
1046-
print("redirect_url=", redirect_url)
10471051
if request_url != redirect_url:
1052+
print("redirecting original=" + request_url + " to new=" + redirect_url)
10481053
redirect(urllib.parse.urlunparse(redirect_url), 301)
10491054

10501055

0 commit comments

Comments
 (0)