wagtail-nest / wagtail-bakery

A set of helpers for baking your Django Wagtail site out as flat files.
MIT License
182 stars 40 forks source link

Generated pages are blank when SECURE_SSL_REDIRECT is enabled #24

Open loicteixeira opened 6 years ago

loicteixeira commented 6 years ago

It is sometimes required to set SECURE_SSL_REDIRECT to True in the settings (e.g. you can't force the redirection before the request reaches Django). When you do so however, the generated pages will be completely blank.

This is because the request is not set as secure: https://github.com/moorinteractive/wagtail-bakery/blob/4c2979956a9601ffd25811314e90b31f713e60c6/src/wagtailbakery/views.py#L91-L92

Which returns a HttpResponsePermanentRedirect which isn't handled (it reaches the 3rd if branch where reponse.content is b''): https://github.com/moorinteractive/wagtail-bakery/blob/4c2979956a9601ffd25811314e90b31f713e60c6/src/wagtailbakery/views.py#L31-L40

While there might be some discussions to have on how a HttpResponsePermanentRedirect should be handled, I reckon this is for another issue and that the right fix here is to set the request as secure. I'll open a PR shortly.