fix(seo): https still broken on -test — key site_scheme off DJANGO_ENV not DEBUG (#1236)#1332
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
PR #1330 fixed #1236 by pinning
httpswhennot DEBUG, assumingDEBUG=Truemeant local dev. The test server runs
DEBUG=True(config-test.ini) whilesitting behind the same TLS-terminating Apache proxy as prod — so
site_schemereturned
request.scheme(http) there. Verified on the live deploy:Net effect: #1236 was fixed on prod (where
DJANGO_ENV=PRODforcesDEBUG=False) but not on test. Everything else from #1330 verified correct ontest (canonical = singular
/project/<short_name>/, Twitter Cards, JSON-LDOrganization/Person/NewsArticle, per-page descriptions).
The fix
Key
site_schemeoffDJANGO_ENVinstead ofDEBUG:'PROD'/'TEST'(set byrebuildanddeploy.shon the servers) →https'DEBUG'/unset (local dev) →request.schemeAlso make the
site_schemecontext processor delegate towebsite.utils.metadata.site_scheme(single source of truth) so the template(canonical/OG) and view (JSON-LD) URL schemes can't drift.
Tests
DJANGO_ENV=TEST+DEBUG=Truemust still emit https`.Verify after merge
On
makeabilitylab-test, confirmog:url/og:image/canonicalare nowhttps://(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 makerequest.schemecorrecteverywhere and let this workaround be removed.
🤖 Generated with Claude Code