Skip to content

Commit d4231e0

Browse files
[DURACOM-344] adapt patterns and example file, fix possible error from YAML
(cherry picked from commit 4c96381)
1 parent 4bb7b54 commit d4231e0

6 files changed

Lines changed: 40 additions & 21 deletions

File tree

config/config.example.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ ssr:
2323
# Determining which styles are critical is a relatively expensive operation; this option is
2424
# disabled (false) by default to boost server performance at the expense of loading smoothness.
2525
inlineCriticalCss: false
26-
# Regexes to be run against the path of the page to check if SSR is allowed.
26+
# Patterns to be run as regexes against the path of the page to check if SSR is allowed.
2727
# If the path match any of the regexes it will be served directly in CSR.
2828
# By default, excludes community and collection browse, global browse, global search, community list, and statistics.
29-
excludePathRegexes: [
30-
/^\/communities\/[ 0-9a-f ]{ 8 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 12 }\/browse(\/.*)?$/i,
31-
/^\/collections\/[ 0-9a-f ]{ 8 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 12 }\/browse(\/.*)?$/i,
32-
/^\/browse\//,
33-
/^\/search$/,
34-
/^\/community-list$/,
35-
/^\/statistics$/,
36-
]
29+
excludePathPatterns:
30+
- /^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i
31+
- /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i
32+
- /^\/browse\//
33+
- /^\/search$/
34+
- /^\/community-list$/
35+
- /^\/statistics\//
36+
- /^\/admin$/
37+
- /^\/processes$/
38+
- /^\/notifications$/
39+
- /^\/health$/
40+
3741
# Whether to enable rendering of Search component on SSR.
3842
# If set to true the component will be included in the HTML returned from the server side rendering.
3943
# If set to false the component will not be included in the HTML returned from the server side rendering.

server.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function app() {
221221
* The callback function to serve server side angular
222222
*/
223223
function ngApp(req, res, next) {
224-
if (environment.ssr.enabled && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.ssr.excludePathRegexes))) {
224+
if (environment.ssr.enabled && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.ssr.excludePathPatterns))) {
225225
// Render the page to user via SSR (server side rendering)
226226
serverSideRender(req, res, next);
227227
} else {
@@ -631,10 +631,13 @@ function start() {
631631
* Check if SSR should be skipped for path
632632
*
633633
* @param path
634-
* @param excludePathRegexes
634+
* @param excludePathPattern
635635
*/
636-
function isExcludedFromSsr(path: string, excludePathRegexes: RegExp[]): boolean {
637-
return excludePathRegexes.some((regex) => regex.test(path));
636+
function isExcludedFromSsr(path: string, excludePathPattern: (string | RegExp)[]): boolean {
637+
return excludePathPattern.some((pattern) => {
638+
const regex = new RegExp(pattern);
639+
return regex.test(path)
640+
});
638641
}
639642

640643
/*

src/config/ssr-config.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export interface SSRConfig extends Config {
3939
replaceRestUrl: boolean;
4040

4141
/**
42-
* Regexes to match url's path and check if SSR is disabled for it.
42+
* Patterns to be used as regexes to match url's path and check if SSR is disabled for it.
4343
*/
44-
excludePathRegexes: RegExp[];
44+
excludePathPatterns: (string | RegExp)[];
4545

4646
/**
4747
* Whether to enable rendering of search component on SSR

src/environments/environment.production.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ export const environment: Partial<BuildConfig> = {
1010
inlineCriticalCss: false,
1111
transferState: true,
1212
replaceRestUrl: true,
13-
excludePathRegexes: [
13+
excludePathPatterns: [
1414
/^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
1515
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
1616
/^\/browse\//,
1717
/^\/search$/,
1818
/^\/community-list$/,
19-
/^\/statistics$/,
19+
/^\/statistics\//,
20+
/^\/admin$/,
21+
/^\/processes$/,
22+
/^\/notifications$/,
23+
/^\/health$/,
2024
],
2125
enableSearchComponent: false,
2226
enableBrowseComponent: false,

src/environments/environment.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ export const environment: BuildConfig = {
1414
inlineCriticalCss: false,
1515
transferState: true,
1616
replaceRestUrl: false,
17-
excludePathRegexes: [
17+
excludePathPatterns: [
1818
/^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
1919
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
2020
/^\/browse\//,
2121
/^\/search$/,
2222
/^\/community-list$/,
23-
/^\/statistics$/,
23+
/^\/statistics\//,
24+
/^\/admin$/,
25+
/^\/processes$/,
26+
/^\/notifications$/,
27+
/^\/health$/,
2428
],
2529
enableSearchComponent: false,
2630
enableBrowseComponent: false,

src/environments/environment.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ export const environment: Partial<BuildConfig> = {
1515
inlineCriticalCss: false,
1616
transferState: true,
1717
replaceRestUrl: false,
18-
excludePathRegexes: [
18+
excludePathPatterns: [
1919
/^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
2020
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
2121
/^\/browse\//,
2222
/^\/search$/,
2323
/^\/community-list$/,
24-
/^\/statistics$/,
24+
/^\/statistics\//,
25+
/^\/admin$/,
26+
/^\/processes$/,
27+
/^\/notifications$/,
28+
/^\/health$/,
2529
],
2630
enableSearchComponent: false,
2731
enableBrowseComponent: false,

0 commit comments

Comments
 (0)