Architecture: How to make Angular SPA legal pages bot-readable for A2P cam...

Documentation for Sessions

🏗️ Architecture: How to make Angular SPA legal pages bot-readable for A2P cam...

Date: 2026-03-02
Time: 21:02:47 UTC
Session: gspace1-166.10
Agent: angular
Confidence: 92%
Status: ✅ Documented


📋 Decision Context

Question:

How to make Angular SPA legal pages bot-readable for A2P campaign TCR verification

Task: Fix legal pages bot-readability for A2P campaign


🎯 Decision Made

Chosen:

Post-build static HTML generation script (tools/scripts/build/prerender-legal-pages.js) that extracts English content from Angular templates and injects it into the Angular shell HTML with full SEO meta tags, JSON-LD, and OG/Twitter tags. Runs automatically after nx build via package.json.

Options Considered:

  1. Angular 20 SSR prerender (outputMode: 'static') — blocked by window error in route extraction
  2. Post-build script to generate static HTML from templates — practical, reliable
  3. Cloudflare Workers to detect bots and serve different content — infrastructure complexity
  4. Standalone static HTML files outside Angular — loses Angular hydration

💭 Reasoning

Angular 20 SSR prerender (outputMode: 'static') was the ideal solution and the infrastructure was already built (main.server.ts, app.config.server.ts, app.routes.server.ts, ssr-browser-shim.ts). However, it fails with 'window is not defined' during route extraction — a deep SSR compatibility issue across 238+ libraries. Fixing this requires auditing every library for top-level window references, which is impractical for the immediate A2P campaign need. The post-build script approach generates the same result (bot-readable HTML with full content + Angular scripts for hydration) without requiring SSR compatibility.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation