mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-344] adapt patterns and example file, fix possible error from YAML
This commit is contained in:
@@ -23,17 +23,21 @@ ssr:
|
|||||||
# Determining which styles are critical is a relatively expensive operation; this option is
|
# 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.
|
# disabled (false) by default to boost server performance at the expense of loading smoothness.
|
||||||
inlineCriticalCss: false
|
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.
|
# 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.
|
# By default, excludes community and collection browse, global browse, global search, community list, and statistics.
|
||||||
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,
|
- /^\/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,
|
- /^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i
|
||||||
/^\/browse\//,
|
- /^\/browse\//
|
||||||
/^\/search$/,
|
- /^\/search$/
|
||||||
/^\/community-list$/,
|
- /^\/community-list$/
|
||||||
/^\/statistics$/,
|
- /^\/statistics\//
|
||||||
]
|
- /^\/admin$/
|
||||||
|
- /^\/processes$/
|
||||||
|
- /^\/notifications$/
|
||||||
|
- /^\/health$/
|
||||||
|
|
||||||
# Whether to enable rendering of Search component on SSR.
|
# 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 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.
|
# If set to false the component will not be included in the HTML returned from the server side rendering.
|
||||||
|
11
server.ts
11
server.ts
@@ -221,7 +221,7 @@ export function app() {
|
|||||||
* The callback function to serve server side angular
|
* The callback function to serve server side angular
|
||||||
*/
|
*/
|
||||||
function ngApp(req, res, next) {
|
function ngApp(req, res, next) {
|
||||||
if (environment.ssr.enabled && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.ssr.excludePathRegexes))) {
|
if (environment.ssr.enabled && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.ssr.excludePathPatterns))) {
|
||||||
// Render the page to user via SSR (server side rendering)
|
// Render the page to user via SSR (server side rendering)
|
||||||
serverSideRender(req, res, next);
|
serverSideRender(req, res, next);
|
||||||
} else {
|
} else {
|
||||||
@@ -631,10 +631,13 @@ function start() {
|
|||||||
* Check if SSR should be skipped for path
|
* Check if SSR should be skipped for path
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* @param excludePathRegexes
|
* @param excludePathPattern
|
||||||
*/
|
*/
|
||||||
function isExcludedFromSsr(path: string, excludePathRegexes: RegExp[]): boolean {
|
function isExcludedFromSsr(path: string, excludePathPattern: (string | RegExp)[]): boolean {
|
||||||
return excludePathRegexes.some((regex) => regex.test(path));
|
return excludePathPattern.some((pattern) => {
|
||||||
|
const regex = new RegExp(pattern);
|
||||||
|
return regex.test(path)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -39,9 +39,9 @@ export interface SSRConfig extends Config {
|
|||||||
replaceRestUrl: boolean;
|
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
|
* Whether to enable rendering of search component on SSR
|
||||||
|
@@ -10,13 +10,17 @@ export const environment: Partial<BuildConfig> = {
|
|||||||
inlineCriticalCss: false,
|
inlineCriticalCss: false,
|
||||||
transferState: true,
|
transferState: true,
|
||||||
replaceRestUrl: 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,
|
/^\/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,
|
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
|
||||||
/^\/browse\//,
|
/^\/browse\//,
|
||||||
/^\/search$/,
|
/^\/search$/,
|
||||||
/^\/community-list$/,
|
/^\/community-list$/,
|
||||||
/^\/statistics$/,
|
/^\/statistics\//,
|
||||||
|
/^\/admin$/,
|
||||||
|
/^\/processes$/,
|
||||||
|
/^\/notifications$/,
|
||||||
|
/^\/health$/,
|
||||||
],
|
],
|
||||||
enableSearchComponent: false,
|
enableSearchComponent: false,
|
||||||
enableBrowseComponent: false,
|
enableBrowseComponent: false,
|
||||||
|
@@ -14,13 +14,17 @@ export const environment: BuildConfig = {
|
|||||||
inlineCriticalCss: false,
|
inlineCriticalCss: false,
|
||||||
transferState: true,
|
transferState: true,
|
||||||
replaceRestUrl: false,
|
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,
|
/^\/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,
|
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
|
||||||
/^\/browse\//,
|
/^\/browse\//,
|
||||||
/^\/search$/,
|
/^\/search$/,
|
||||||
/^\/community-list$/,
|
/^\/community-list$/,
|
||||||
/^\/statistics$/,
|
/^\/statistics\//,
|
||||||
|
/^\/admin$/,
|
||||||
|
/^\/processes$/,
|
||||||
|
/^\/notifications$/,
|
||||||
|
/^\/health$/,
|
||||||
],
|
],
|
||||||
enableSearchComponent: false,
|
enableSearchComponent: false,
|
||||||
enableBrowseComponent: false,
|
enableBrowseComponent: false,
|
||||||
|
@@ -15,13 +15,17 @@ export const environment: Partial<BuildConfig> = {
|
|||||||
inlineCriticalCss: false,
|
inlineCriticalCss: false,
|
||||||
transferState: true,
|
transferState: true,
|
||||||
replaceRestUrl: false,
|
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,
|
/^\/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,
|
/^\/collections\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/browse(\/.*)?$/i,
|
||||||
/^\/browse\//,
|
/^\/browse\//,
|
||||||
/^\/search$/,
|
/^\/search$/,
|
||||||
/^\/community-list$/,
|
/^\/community-list$/,
|
||||||
/^\/statistics$/,
|
/^\/statistics\//,
|
||||||
|
/^\/admin$/,
|
||||||
|
/^\/processes$/,
|
||||||
|
/^\/notifications$/,
|
||||||
|
/^\/health$/,
|
||||||
],
|
],
|
||||||
enableSearchComponent: false,
|
enableSearchComponent: false,
|
||||||
enableBrowseComponent: false,
|
enableBrowseComponent: false,
|
||||||
|
Reference in New Issue
Block a user