{{ request.scheme }} is not honoring https

I am on localhost and {{ request.scheme }} in my template is correct.

But on my private IP’s domain which is https, {{ request.scheme }} is getting output as http only. Now I can’t go about sending 'SITE_URL': settings.SITE_URL, to each and every view.

How can I get {{ request.scheme }} to output https ?

It’s likely you need to set SECURE_PROXY_SSL_HEADER to let Django know you’re running under HTTPS.

If that’s not available I documented a WSGI middleware approach at the end of the post here: CSRF and Trusted Origins in Django 4.x+.

Thanks @carltongibson - you don’t know how much a life-saver this has been.

1 Like

Glad to be of help! :dancer:

You could like back to the forum post from that issue comment if you liked, so others could find the wonderful world of the Django Forum :partying_face:

1 Like