feat(ssr): spider-only SSR serve CSR shell for regular users #11
@@ -25,12 +25,35 @@ const appEngine = new AngularNodeAppEngine();
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the static browser index.html path.
|
* 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 {
|
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);
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user