feat(ssr): spider-only SSR serve CSR shell for regular users #11

Merged
kfj001 merged 5 commits from bugfix/spider-ssr-gate into main 2026-08-08 21:11:32 -07:00
Showing only changes of commit 1b387700d3 - Show all commits
+14 -2
View File
@@ -72,7 +72,17 @@ const COLOR_MAP: ReadonlyArray<{ field: keyof StationConfig; prop: string }> = [
];
/**
* Resolve the static browser index.html path.
* Resolve the static CSR shell path (index.csr.html).
*
* IMPORTANT: We MUST prefer index.csr.html over index.html.
* The Angular build with prerender config produces both:
* - index.html: prerendered at build time with stale DEFAULT_CONFIG baked in
* - index.csr.html: pure CSR shell with empty <app-root> — Angular hydrates client-side
*
* Serving index.html to regular users causes the flash: the prerendered DOM
* shows stale build-time content until Angular re-renders with fresh data.
* Even with window.__STATION_CONFIG injection, the prerendered innerHTML inside
* <app-root> still shows old content on the first paint.
*
* Production (Docker): browser files are copied to /usr/share/nginx/html/
* Local dev (ng build): browser files live in dist/radio-station/browser/
@@ -80,9 +90,11 @@ const COLOR_MAP: ReadonlyArray<{ field: keyof StationConfig; prop: string }> = [
*/
function browserIndexPath(): string {
// Production path — Dockerfile copies browser output here
// CSR shell first — avoid prerendered index.html with stale content
const productionPaths = [
'/usr/share/nginx/html/index.html',
'/usr/share/nginx/html/index.csr.html',
'/usr/share/nginx/html/index.html',
'/var/www/html/index.csr.html',
'/var/www/html/index.html',
];