Skip to content

fix(seo): https still broken on -test — key site_scheme off DJANGO_ENV not DEBUG (#1236)#1332

Merged
jonfroehlich merged 1 commit into
masterfrom
1236-https-scheme-djangoenv
Jun 18, 2026
Merged

fix(seo): https still broken on -test — key site_scheme off DJANGO_ENV not DEBUG (#1236)#1332
jonfroehlich merged 1 commit into
masterfrom
1236-https-scheme-djangoenv

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

The bug

PR #1330 fixed #1236 by pinning https when not DEBUG, assuming DEBUG=True
meant local dev. The test server runs DEBUG=True (config-test.ini) while
sitting behind the same TLS-terminating Apache proxy as prod — so site_scheme
returned request.scheme (http) there. Verified on the live deploy:

makeabilitylab-test … canonical / og:url / og:image  → http://   (✗ still #1236)

Net effect: #1236 was fixed on prod (where DJANGO_ENV=PROD forces
DEBUG=False) but not on test. Everything else from #1330 verified correct on
test (canonical = singular /project/<short_name>/, Twitter Cards, JSON-LD
Organization/Person/NewsArticle, per-page descriptions).

The fix

Key site_scheme off DJANGO_ENV instead of DEBUG:

  • 'PROD'/'TEST' (set by rebuildanddeploy.sh on the servers) → https
  • 'DEBUG'/unset (local dev) → request.scheme

Also make the site_scheme context processor delegate to
website.utils.metadata.site_scheme (single source of truth) so the template
(canonical/OG) and view (JSON-LD) URL schemes can't drift.

Tests

  • Replaced the DEBUG-based assertions with DJANGO_ENV-based ones.
  • Added a regression test: DJANGO_ENV=TEST + DEBUG=True must still emit https`.
  • Full suite: 267 pass, 1 skipped.

Verify after merge

On makeabilitylab-test, confirm og:url/og:image/canonical are now https://
(home + a project/member/news page). This is a template/view-only change — no schema
change, so no migration/restart risk this time.

Follow-up #1329 (IT: SECURE_PROXY_SSL_HEADER) would make request.scheme correct
everywhere and let this workaround be removed.

🤖 Generated with Claude Code

… broken on -test (#1236)

The #1236 fix pinned https only when `not DEBUG`, assuming DEBUG=True meant local
dev. But the TEST server runs DEBUG=True (config-test.ini) while sitting behind the
same TLS-terminating Apache proxy as prod, so `site_scheme` returned `request.scheme`
(http) there — every canonical/og:url/og:image on makeabilitylab-test emitted
http://, i.e. #1236 was only fixed on prod, not test. (Confirmed by inspecting the
live test pages after deploy.)

Key off `DJANGO_ENV` instead: 'PROD'/'TEST' on the servers (set by
rebuildanddeploy.sh) → https; 'DEBUG'/unset locally → request.scheme. Make the
`site_scheme` context processor delegate to `website.utils.metadata.site_scheme` so
the template (canonical/OG) and view (JSON-LD) URL schemes share one definition and
can't drift.

Tests: replace the DEBUG-based assertions with DJANGO_ENV-based ones and add an
explicit regression test that DJANGO_ENV=TEST + DEBUG=True still emits https.
Full suite 267 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonfroehlich jonfroehlich merged commit 5faf178 into master Jun 18, 2026
2 checks passed
@jonfroehlich jonfroehlich deleted the 1236-https-scheme-djangoenv branch June 22, 2026 20:35
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.

Project page social media (opengraph) not working perfectly

1 participant