Skip to content

Remove site_scheme workaround; rely on request.scheme (closes #1329)#1343

Merged
jonfroehlich merged 1 commit into
masterfrom
1329-remove-site-scheme-workaround
Jun 18, 2026
Merged

Remove site_scheme workaround; rely on request.scheme (closes #1329)#1343
jonfroehlich merged 1 commit into
masterfrom
1329-remove-site-scheme-workaround

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Final piece of #1329. Builds on #1336 (enabled SECURE_PROXY_SSL_HEADER on TEST/PROD) and #1338 (which verified end-to-end on -test that /sitemap.xml emits https from raw request.scheme). Closes #1329.

What

Now that Django sees the real https scheme behind UW CSE's TLS proxy, the in-app site_scheme workaround from #1236 is redundant. This removes it and relies on the framework:

  • Delete the site_scheme context processor (and its TEMPLATES registration in settings.py) and the site_scheme helper in website/utils/metadata.py.
  • absolute_url() — used by views for JSON-LD url/image/logo — now builds from request.scheme.
  • Templates (base.html, member.html, news_item.html, project.html) build canonical / OG / Twitter image URLs from {{ request.scheme }} instead of {{ site_scheme }}.

Net -77/+63 lines; one fewer context processor running on every request.

Tests

Reworked the scheme assertions in test_page_metadata.py to exercise the real mechanism rather than the deleted DJANGO_ENV branch:

  • test_forwarded_proto_header_drives_https — an X-Forwarded-Proto: https request under @override_settings(SECURE_PROXY_SSL_HEADER=...) emits https absolute URLs (the deployed path; also sends a clean Host header as Apache does).
  • test_secure_request_uses_https — a secure=True request emits https.
  • test_local_dev_uses_request_scheme — a plain http request reflects the request scheme (http).
  • PageMetadataHttpsTests now issues secure=True requests instead of forcing DJANGO_ENV='PROD'.

Full suite green in-container: 344 tests, OK (skipped=1) (--settings=makeabilitylab.settings_test).

Verification after merge → -test

Behavior should be unchanged (URLs were already https via the workaround). Confirm canonical / og:url / og:image still render https:// on a few page types (home, a project, a member, a news item). The win is that this is now driven by the framework, not a hardcoded override.

Note on prod

Prod still rides on SECURE_PROXY_SSL_HEADER (already verified on -test); it only takes effect in prod when you cut the next SemVer tag.

🤖 Generated with Claude Code

With SECURE_PROXY_SSL_HEADER enabled (#1336) and verified end-to-end via
the sitemap on -test (#1338), request.scheme is now correct everywhere
behind UW CSE's TLS proxy. Remove the in-app site_scheme workaround that
pinned https off DJANGO_ENV (#1236) and rely on the framework:

- Delete the site_scheme context processor (+ its TEMPLATES registration)
  and the site_scheme helper in website/utils/metadata.py.
- absolute_url() (view-built JSON-LD URLs) now uses request.scheme.
- Templates (base/member/news_item/project) build canonical/OG/Twitter
  URLs from {{ request.scheme }} instead of {{ site_scheme }}.

Tests: rework the scheme assertions to exercise the real mechanism —
an X-Forwarded-Proto: https request under SECURE_PROXY_SSL_HEADER emits
https; a secure request emits https; a plain http request reflects the
request scheme. Full suite green (344 tests).

Closes #1329.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonfroehlich jonfroehlich merged commit ea1e067 into master Jun 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable SECURE_PROXY_SSL_HEADER so Django sees the real https scheme (supersedes in-app workaround)

1 participant