diff --git a/config/config.example.yml b/config/config.example.yml index f207d05add..2b905148cd 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -23,17 +23,21 @@ universal: # Determining which styles are critical is a relatively expensive operation; this option is # disabled (false) by default to boost server performance at the expense of loading smoothness. inlineCriticalCss: false - # Regexes to be run against the path of the page to check if SSR is allowed. + # Patterns to be run as regexes against the path of the page to check if SSR is allowed. # If the path match any of the regexes it will be served directly in CSR. # By default, excludes community and collection browse, global browse, global search, community list, and statistics. - excludePathRegexes: [ - /^\/communities\/[ 0-9a-f ]{ 8 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 12 }\/browse(\/.*)?$/i, - /^\/collections\/[ 0-9a-f ]{ 8 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 4 }-[ 0-9a-f ]{ 12 }\/browse(\/.*)?$/i, - /^\/browse\//, - /^\/search$/, - /^\/community-list$/, - /^\/statistics$/, - ] + excludePathPatterns: + - /^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i + - /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i + - /^\/browse\// + - /^\/search$/ + - /^\/community-list$/ + - /^\/statistics\// + - /^\/admin$/ + - /^\/processes$/ + - /^\/notifications$/ + - /^\/health$/ + # Whether to enable rendering of Search component on SSR. # If set to true the component will be included in the HTML returned from the server side rendering. # If set to false the component will not be included in the HTML returned from the server side rendering. diff --git a/server.ts b/server.ts index 28f356e0ca..a44407c0fc 100644 --- a/server.ts +++ b/server.ts @@ -629,10 +629,13 @@ function start() { * Check if SSR should be skipped for path * * @param path - * @param excludePathRegexes + * @param excludePathPattern */ -function isExcludedFromSsr(path: string, excludePathRegexes: RegExp[]): boolean { - return excludePathRegexes.some((regex) => regex.test(path)); +function isExcludedFromSsr(path: string, excludePathPattern: (string | RegExp)[]): boolean { + return excludePathPattern.some((pattern) => { + const regex = new RegExp(pattern); + return regex.test(path) + }); } /* diff --git a/src/config/universal-config.interface.ts b/src/config/universal-config.interface.ts index 417023ddf0..215730f75e 100644 --- a/src/config/universal-config.interface.ts +++ b/src/config/universal-config.interface.ts @@ -32,9 +32,9 @@ export interface UniversalConfig extends Config { replaceRestUrl: boolean; /** - * Regexes to match url's path and check if SSR is disabled for it. + * Patterns to be used as regexes to match url's path and check if SSR is disabled for it. */ - excludePathRegexes: RegExp[]; + excludePathPatterns: (string | RegExp)[]; /** * Whether to enable rendering of search component on SSR diff --git a/src/environments/environment.production.ts b/src/environments/environment.production.ts index a5d132a39d..3fb08629e0 100644 --- a/src/environments/environment.production.ts +++ b/src/environments/environment.production.ts @@ -11,13 +11,17 @@ export const environment: Partial = { inlineCriticalCss: false, transferState: true, replaceRestUrl: true, - excludePathRegexes: [ + excludePathPatterns: [ /^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/browse\//, /^\/search$/, /^\/community-list$/, - /^\/statistics$/, + /^\/statistics\//, + /^\/admin$/, + /^\/processes$/, + /^\/notifications$/, + /^\/health$/, ], enableSearchComponent: false, enableBrowseComponent: false, diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index ae7fcf69ae..f04e76265c 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -14,13 +14,17 @@ export const environment: BuildConfig = { inlineCriticalCss: false, transferState: true, replaceRestUrl: false, - excludePathRegexes: [ + excludePathPatterns: [ /^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/browse\//, /^\/search$/, /^\/community-list$/, - /^\/statistics$/, + /^\/statistics\//, + /^\/admin$/, + /^\/processes$/, + /^\/notifications$/, + /^\/health$/, ], enableSearchComponent: false, enableBrowseComponent: false, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 168647e964..fb81708cc6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -16,13 +16,17 @@ export const environment: Partial = { inlineCriticalCss: false, transferState: true, replaceRestUrl: false, - excludePathRegexes: [ + excludePathPatterns: [ /^\/communities\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i, /^\/browse\//, /^\/search$/, /^\/community-list$/, - /^\/statistics$/, + /^\/statistics\//, + /^\/admin$/, + /^\/processes$/, + /^\/notifications$/, + /^\/health$/, ], enableSearchComponent: false, enableBrowseComponent: false,