fix(preview): align frame policy and canonical host for Wagtail preview
All checks were successful
CI / nightly-e2e (pull_request) Has been skipped
CI / deploy (pull_request) Has been skipped
CI / ci (pull_request) Successful in 1m32s
CI / pr-e2e (pull_request) Successful in 1m34s

This commit is contained in:
codex_a
2026-03-04 20:51:23 +00:00
parent 99b06d1f3b
commit 4ea1e66cdf
2 changed files with 32 additions and 24 deletions

View File

@@ -7,11 +7,16 @@ python manage.py migrate --noinput
python manage.py collectstatic --noinput
python manage.py update_index
# Set Wagtail site hostname from first entry in ALLOWED_HOSTS
# Set Wagtail site hostname from WAGTAILADMIN_BASE_URL when available.
# This keeps preview/page URLs on the same origin as the admin host.
python manage.py shell -c "
from wagtail.models import Site
import os
hostname = os.environ.get('ALLOWED_HOSTS', 'localhost').split(',')[0].strip()
from urllib.parse import urlparse
admin_base = os.environ.get('WAGTAILADMIN_BASE_URL', '').strip()
parsed = urlparse(admin_base) if admin_base else None
hostname = parsed.hostname if parsed and parsed.hostname else os.environ.get('ALLOWED_HOSTS', 'localhost').split(',')[0].strip()
Site.objects.update(hostname=hostname, port=443, site_name='No Hype AI')
"