miguelgrinberg/Flask-Moment

Moment JS is linked over HTTP when running behind HTTPS proxy

andreaswin opened this issue · 1 comments

My Flask application is running behind Gunicorn and Nginx, with nginx terminating the HTTPS connection and talking to Gunicorn via regular HTTP. In this case, using 'include_moment()' (Flask-Moment v0.2.1) in my Flask application ends up with

<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/%s/moment-with-langs.min.js"></script> 

where %s is the version (Due to line 14 in flask_moment.py). This is because request.is_secure always seems to be False in this type of setup.

This causes the js not to get loaded since the browser is being asked to load the js over HTTP while the main site is served via HTTPS. I have seen that it is possible to use ProxyFix to get around this, but is there any way to resolve this just within Flask-Moment without manually editing flask_moment.py to always link to the script using HTTPS?

Understand if this might not get considered an actual bug but rather a deployment issue, but any insight would be appreciated.

Nevermind this report, this seems to be already fixed in the latest version.