mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 21:13:07 +00:00
fix for 401 requests
This commit is contained in:
@@ -17,6 +17,7 @@ import { ngExpressEngine } from '@nguniversal/express-engine';
|
||||
|
||||
import { ROUTES } from './routes';
|
||||
import { ENV_CONFIG } from './config';
|
||||
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||
|
||||
export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
const app = express();
|
||||
@@ -31,9 +32,21 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
app.use(cookieParser());
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.engine('html', ngExpressEngine({
|
||||
bootstrap: bootstrap
|
||||
}));
|
||||
app.engine('html', (_, options, callback) =>
|
||||
ngExpressEngine({
|
||||
bootstrap: bootstrap,
|
||||
providers: [
|
||||
{
|
||||
provide: REQUEST,
|
||||
useValue: options.req,
|
||||
},
|
||||
{
|
||||
provide: RESPONSE,
|
||||
useValue: options.req.res,
|
||||
},
|
||||
],
|
||||
})(_, options, callback)
|
||||
);
|
||||
|
||||
app.set('view engine', 'html');
|
||||
app.set('views', 'src');
|
||||
@@ -53,8 +66,10 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
function ngApp(req, res) {
|
||||
|
||||
function onHandleError(parentZoneDelegate, currentZone, targetZone, error) {
|
||||
console.warn('Error in SSR, serving for direct CSR');
|
||||
res.sendFile('index.csr.html', { root: './src' });
|
||||
if (!res._headerSent) {
|
||||
console.warn('Error in SSR, serving for direct CSR');
|
||||
res.sendFile('index.csr.html', { root: './src' });
|
||||
}
|
||||
}
|
||||
|
||||
if (ENV_CONFIG.universal.preboot) {
|
||||
|
Reference in New Issue
Block a user