Sync their spec deltas into landing-pages and the new lead-notifications spec, and point the deployment SQL paths at the archive folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
3.6 KiB
3.6 KiB
Design
The full design is docs/superpowers/specs/2026-12-02-custom-html-block-design.md (approved 2026-12-02). This file records the technical decisions.
Context
- Pages store their blocks as JSON in
cms_page.blocks.CmsBlockValidatorin services-counter checks the blocks, and mobile-api passes them to the portal unchanged. - The portal's
middleware.tsgives every page and API response a per-request nonce Content-Security-Policy. Ansrcdocframe would inherit that policy and block the pasted scripts, inline styles and CDN links. So the pasted HTML needs its own response with its own policy. - The public page
/p/[company]/[slug]renders on the server.routeGuard.isPublicPathadmits only^/p/[^/]+/[^/]+$today.
Goals / Non-Goals
Goals:
- Pasted HTML renders as designed.
- It runs with an opaque origin on every path, including a direct visit to the frame address.
Non-Goals:
- SEO for the framed content.
- Working forms inside it.
- An HTML editor.
Decisions
- Route handlers, not pages.
app/p/[company]/[slug]/frame/[block]/route.tsandapp/pages/[id]/preview/frame/[block]/route.tsreturntext/htmldirectly. They reuse the server helpers that the public page (published read) and the preview (admin read with the session token) already use. - Sandbox in two places.
- The response header:
Content-Security-Policy: sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox; frame-ancestors 'self'. This covers a direct visit. - The
<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">attribute. This covers embedding. - There is no
default-srcrestriction, so the AI's CDN scripts, fonts and images load.
- The response header:
- Middleware skips the frame routes. It returns early, with no nonce policy, for paths ending
/frame/<n>under/p/and/pages/<id>/preview/. The preview route still checks the session itself; the middleware's route guard still runs before the early return, so an unsigned preview request is redirected to sign in. - Height script.
- The handler inserts a fixed script before
</body>, or appends it when there is no</body>. The script posts{type: "colite-frame-height", height}toparenton load, on resize and through aResizeObserverondocument.documentElement. - The parent accepts a message only when
event.sourceis that iframe'scontentWindow. It clamps the height to 100–20,000 px, starting at 600.
- The handler inserts a fixed script before
- Not-found. The public handler answers 404 with an empty body for every miss: unknown company or slug, a draft page, a bad index or a non-HTML block. The same rule holds on the public page.
hideHeader. Acms_page.hide_header TINYINT(1) NOT NULL DEFAULT 0column carried through the counter DTO, the mobile-api admin request and the public page response.LandingPageomits the header and the<h1>when it is on.- Limits.
HTMLblocks allow 200,000 characters, about 200 KB for a large AI page. The existing 30-block cap stands. The portal body limit for page saves is checked and raised if it is below the largest page: 30 × 200,000 characters.
Risks / Trade-offs
- Misleading content: staff with
BO_PAGEScan publish misleading content, such as a fake form. The frame contains it, saves are audited, and the role is granted by super admins only. - Cost of each frame: each HTML block is one more request per visit. Pages have at most 30 blocks.
- Relative addresses: a relative asset path in pasted HTML (such as
/logo.png) resolves against the Co-Lite site and breaks. The editor note tells staff to use fullhttps://addresses for images.