From 60ee9fd8b451c503837dff177bcdb915fe775028 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 29 Apr 2012 16:46:19 -0400 Subject: [PATCH] X-Forwarded-Proto[C --- flask_sslify.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/flask_sslify.py b/flask_sslify.py index aa881db..a56380a 100644 --- a/flask_sslify.py +++ b/flask_sslify.py @@ -16,6 +16,13 @@ class SSLify(object): @staticmethod def redirect(): - if (not request.is_secure) and (not app.debug): + + criteria = [ + request.is_secure, + app.debug, + request.headers.get('X-Forwarded-Proto', 'http') == 'https' + ] + + if not any(criteria): url = request.url.replace('http://', 'https://') return redirect(url) \ No newline at end of file