# 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`. `CmsBlockValidator` in services-counter checks the blocks, and mobile-api passes them to the portal unchanged. - The portal's `middleware.ts` gives every page and API response a per-request nonce Content-Security-Policy. An `srcdoc` frame 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.isPublicPath` admits 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 1. **Route handlers, not pages.** `app/p/[company]/[slug]/frame/[block]/route.ts` and `app/pages/[id]/preview/frame/[block]/route.ts` return `text/html` directly. They reuse the server helpers that the public page (published read) and the preview (admin read with the session token) already use. 2. **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 `