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 9561339cf5 - Show all commits
+26 -3
View File
@@ -25,12 +25,35 @@ const appEngine = new AngularNodeAppEngine();
/**
* Resolve the static browser index.html path.
* In the built output the browser files live in the `browser/` subdirectory.
*
* Production (Docker): browser files are copied to /usr/share/nginx/html/
* Local dev (ng build): browser files live in dist/radio-station/browser/
* Try each candidate in order and return the first that exists.
*/
function browserIndexPath(): string {
// __dirname in ESM resolves to this file's directory
// Production path — Dockerfile copies browser output here
const productionPaths = [
'/usr/share/nginx/html/index.html',
'/var/www/html/index.html',
];
// Local dev path — relative to the compiled server directory
const dir = typeof __dirname !== 'undefined' ? __dirname : path.dirname(new URL(import.meta.url).pathname);
return path.join(dir, 'browser', 'index.html');
const localPaths = [
path.join(dir, 'browser', 'index.html'),
path.join(dir, '..', 'browser', 'index.html'),
];
const allCandidates = [...productionPaths, ...localPaths];
for (const candidate of allCandidates) {
try {
if (fs.existsSync(candidate)) return candidate;
} catch {
// ignore — keep trying
}
}
// Return the first candidate so the error path has a sensible value to log
return allCandidates[0];
}
/**