fix(ssr): resolve index.html from production path for CSR shell
CI Pipeline / backend-test (push) Successful in 20m50s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 15s
CI Pipeline / backend-test (pull_request) Successful in 37m43s
CI Pipeline / frontend-test (pull_request) Successful in 45s
CI Pipeline / frontend-build (pull_request) Successful in 39s
CI Pipeline / backend-lint (pull_request) Successful in 16s
CI Pipeline / quality-gate (push) Successful in 5s
CI Pipeline / quality-gate (pull_request) Successful in 4s
CI Pipeline / backend-test (push) Successful in 20m50s
CI Pipeline / frontend-test (push) Successful in 24s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 15s
CI Pipeline / backend-test (pull_request) Successful in 37m43s
CI Pipeline / frontend-test (pull_request) Successful in 45s
CI Pipeline / frontend-build (pull_request) Successful in 39s
CI Pipeline / backend-lint (pull_request) Successful in 16s
CI Pipeline / quality-gate (push) Successful in 5s
CI Pipeline / quality-gate (pull_request) Successful in 4s
The CSR shell path was hardcoded to a local dev directory (app/server/browser/index.html) which does not exist in the Docker container. Browser files are copied to /usr/share/nginx/html by the Dockerfile. browserIndexPath() now checks both production and development paths, falling back to the first that exists.
This commit is contained in:
1 parent
c5d80f4caa
commit
9561339cf5
1 file changed
+26
-3
@@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user