From 7388990c5c215f8795d456c501ace623c36180ef Mon Sep 17 00:00:00 2001 From: Chris Warrick Date: Mon, 17 Aug 2015 14:09:57 +0200 Subject: [PATCH] Patch request URL for fake HTTPS Signed-off-by: Chris Warrick --- coil/web.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coil/web.py b/coil/web.py index 5dd437f..4334919 100644 --- a/coil/web.py +++ b/coil/web.py @@ -345,7 +345,11 @@ def render(template_name, context=None, code=200, headers=None): context['current_user'] = current_user context['_author_get'] = _author_get context['_author_uid_get'] = _author_uid_get - context['permalink'] = request.url + if app.config['COIL_URL'].startswith('https') and not request.url.startswith('https'): + # patch request URL for HTTPS proxy (eg. CloudFlare) + context['permalink'] = request.url.replace('http', 'https', 1) + else: + context['permalink'] = request.url context['url_for'] = url_for headers['Pragma'] = 'no-cache' headers['Cache-Control'] = 'private, max-age=0, no-cache'