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:
- Angular 20 SSR prerender (outputMode: 'static') — blocked by window error in route extraction
- Post-build script to generate static HTML from templates — practical, reliable
- Cloudflare Workers to detect bots and serve different content — infrastructure complexity
- 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
tools/scripts/build/prerender-legal-pages.jsapps/gograb-space/project.jsonpackage.jsonlibs/libs-structural/legal-lib/src/lib/components/privacy-policy/privacy-policy.component.tslibs/libs-structural/legal-lib/src/lib/components/terms-of-use/terms-of-use.component.tslibs/libs-structural/legal-lib/src/lib/components/legal-guide/legal-guide.component.tslibs/libs-foundational/brand-seo/src/lib/services/seo.service.ts
🔗 Related
- Decision ID:
dev_1772485367977_juaj1tn - Session: 166
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation