mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
Using a single index file. Updated servers. Removed duplicate npm scripts.
This commit is contained in:
@@ -41,6 +41,7 @@ app.engine('.html', createEngine({
|
||||
]
|
||||
}));
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
app.set('address', process.env.ADDRESS || '127.0.0.1');
|
||||
app.set('views', __dirname);
|
||||
app.set('view engine', 'html');
|
||||
app.set('json spaces', 2);
|
||||
@@ -72,16 +73,26 @@ app.get('/data.json', serverApi);
|
||||
app.use('/api', createMockApi());
|
||||
|
||||
function ngApp(req, res) {
|
||||
res.render('index', {
|
||||
req,
|
||||
res,
|
||||
// time: true, // use this to determine what part of your app is slow only in development
|
||||
async: true,
|
||||
preboot: true,
|
||||
baseUrl: '/',
|
||||
requestUrl: req.originalUrl,
|
||||
originUrl: `http://localhost:${app.get('port')}`
|
||||
|
||||
function onHandleError(parentZoneDelegate, currentZone, targetZone, error) {
|
||||
console.warn('Error in SSR, serving for direct CSR');
|
||||
res.sendFile('index.html', { root: './src' });
|
||||
return false;
|
||||
}
|
||||
|
||||
Zone.current.fork({ name: 'CSR fallback', onHandleError }).run(() => {
|
||||
res.render('index', {
|
||||
req,
|
||||
res,
|
||||
// time: true, // use this to determine what part of your app is slow only in development
|
||||
async: true,
|
||||
preboot: true,
|
||||
baseUrl: '/',
|
||||
requestUrl: req.originalUrl,
|
||||
originUrl: `http://${app.get('address')}:${app.get('port')}`
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,5 +113,5 @@ app.get('*', function(req, res) {
|
||||
|
||||
// Server
|
||||
let server = app.listen(app.get('port'), () => {
|
||||
console.log(`Listening on: http://localhost:${server.address().port}`);
|
||||
console.log(`Listening on: http://${server.address().address}:${server.address().port}`);
|
||||
});
|
||||
|
Reference in New Issue
Block a user