[DURACOM-344] Adapt SSR page filtering mechanism to a not allowed list

This commit is contained in:
FrancescoMolinaro
2025-04-22 16:16:27 +02:00
parent fbbf16f387
commit ce0f6153b9
6 changed files with 48 additions and 10 deletions

View File

@@ -241,7 +241,7 @@ export function app() {
* The callback function to serve server side angular
*/
function ngApp(req, res) {
if (environment.universal.preboot && req.method === 'GET' && (req.path === '/' || environment.universal.paths.some(pathPrefix => req.path.startsWith(pathPrefix)))) {
if (environment.universal.preboot && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.universal.excludePathRegexes))) {
// Render the page to user via SSR (server side rendering)
serverSideRender(req, res);
} else {
@@ -625,6 +625,16 @@ function start() {
}
}
/**
* Check if SSR should be skipped for path
*
* @param path
* @param excludePathRegexes
*/
function isExcludedFromSsr(path: string, excludePathRegexes: RegExp[]): boolean {
return excludePathRegexes.some((regex) => regex.test(path));
}
/*
* The callback function to serve health check requests
*/