File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1022,6 +1022,12 @@ def redirect_to_canonical_host():
1022
1022
request_url = urllib .parse .urlparse (request .url )
1023
1023
redirect_url = request_url
1024
1024
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
+
1025
1031
# Disable redirects on the health check endpoint.
1026
1032
if request_url .path == "/health" :
1027
1033
return
@@ -1042,9 +1048,8 @@ def redirect_to_canonical_host():
1042
1048
elif redirect_url .path == "/" + prefix :
1043
1049
redirect_url = redirect_url ._replace (path = "/" )
1044
1050
1045
- print ("request_url=" , request_url )
1046
- print ("redirect_url=" , redirect_url )
1047
1051
if request_url != redirect_url :
1052
+ print ("redirecting original=" + request_url + " to new=" + redirect_url )
1048
1053
redirect (urllib .parse .urlunparse (redirect_url ), 301 )
1049
1054
1050
1055
You can’t perform that action at this time.
0 commit comments