FlaskBB
A lightweight forum software in Flask
Member
Joined:
Posts: 11

This is a great project!

I am having trouble on my site getting https: to be enforced, I wonder if you could help. I have set PREFERRED_URL_SCHEME = "HTTPS". When I click 'Login' I am taken to HTTP version of the login page. If I manually change URL to 'https:' I get to the right page, so https is working, its just the link is going to the http version!

I am using 'Pythonanywhere' so can't do this at webserver level.

Thanks for your help

Administrator
avatar
Joined:
Posts: 139

Try setting it in lowercase i.e. "https" and let me know if that works :)


Cheers! 🍻

Member
Joined:
Posts: 11

Hi sh4nks,

Thanks for the reply. That didn't work. Still getting to the http version

Administrator
avatar
Joined:
Posts: 139

You probably can solve it by using a middleware which will enforce https on all routes. I'll post the code when I am on my computer.


Cheers! 🍻

Member
Joined:
Posts: 11

Thanks!

Administrator
avatar
Joined:
Posts: 139

See this commit:
https://github.com/sh4nks/flaskbb/commit/32ddf5860da344c3a9ccf445e14e3bcb173a5354

Uncomment the line
flaskbb.wsgi_app = ReverseProxyPathFix(flaskbb.wsgi_app)
and add force_https=True
i.e.
flaskbb.wsgi_app = ReverseProxyPathFix(flaskbb.wsgi_app, force_https=True)

lmk if it works :)


Cheers! 🍻

Administrator
avatar
Joined:
Posts: 139

btw, someone contributed a somewhat unofficial installation guide for pythonanywhere - did you see those docs?
https://flaskbb.readthedocs.io/en/latest/installation.html#id7


Cheers! 🍻

Member
Joined:
Posts: 11

Thanks sh4nks

I have had to drop the project for a few days. Will try again soon

Administrator
avatar
Joined:
Posts: 139

Jimnotgym wrote:

Thanks sh4nks

I have had to drop the project for a few days. Will try again soon

and, did it work?


Cheers! 🍻

Member
Joined:
Posts: 11

Sorry for not replying sooner. I got frustrated with Pythonanywhere and have got a site running on Linode. However I think you answer would have worked