mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
ensure CSR fallback only happens on actual errors
This commit is contained in:
16
server.ts
16
server.ts
@@ -33,7 +33,7 @@ import { enableProdMode, NgModuleFactory, Type } from '@angular/core';
|
|||||||
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||||
import { environment } from './src/environments/environment';
|
import { environment } from './src/environments/environment';
|
||||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||||
import { hasValue } from './src/app/shared/empty.util';
|
import { hasValue, hasNoValue } from './src/app/shared/empty.util';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set path for the browser application's dist folder
|
* Set path for the browser application's dist folder
|
||||||
@@ -140,12 +140,16 @@ function ngApp(req, res) {
|
|||||||
baseUrl: environment.ui.nameSpace,
|
baseUrl: environment.ui.nameSpace,
|
||||||
originUrl: environment.ui.baseUrl,
|
originUrl: environment.ui.baseUrl,
|
||||||
requestUrl: req.originalUrl
|
requestUrl: req.originalUrl
|
||||||
}, (err) => {
|
}, (err, data) => {
|
||||||
console.warn('Error in SSR, serving for direct CSR.');
|
if (hasNoValue(err) && hasValue(data)) {
|
||||||
if (hasValue(err)) {
|
res.send(data);
|
||||||
console.warn('Error details : ', err);
|
} else {
|
||||||
|
console.warn('Error in SSR, serving for direct CSR.');
|
||||||
|
if (hasValue(err)) {
|
||||||
|
console.warn('Error details : ', err);
|
||||||
|
}
|
||||||
|
res.sendFile(DIST_FOLDER + '/index.html');
|
||||||
}
|
}
|
||||||
res.sendFile(DIST_FOLDER + '/index.html');
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// If preboot is disabled, just serve the client
|
// If preboot is disabled, just serve the client
|
||||||
|
Reference in New Issue
Block a user