Revision 45786
Added by Argiro Kokogiannaki about 7 years ago
server.aot.ts | ||
---|---|---|
76 | 76 |
app.get('/data.json', serverApi); |
77 | 77 |
app.use('/api', createTodoApi()); |
78 | 78 |
|
79 |
process.on('uncaughtException', function (err) { |
|
80 |
console.error('Catching uncaught errors to avoid process crash', err); |
|
81 |
}); |
|
82 |
|
|
79 | 83 |
function ngApp(req, res) { |
80 |
res.render('index', { |
|
81 |
req, |
|
82 |
res, |
|
83 |
// time: true, // use this to determine what part of your app is slow only in development |
|
84 |
preboot: false, |
|
85 |
baseUrl: '/', |
|
86 |
requestUrl: req.originalUrl, |
|
87 |
originUrl: `http://localhost:${ app.get('port') }` |
|
84 |
|
|
85 |
function onHandleError(parentZoneDelegate, currentZone, targetZone, error) { |
|
86 |
console.warn('Error in SSR, serving for direct CSR'); |
|
87 |
res.sendFile('index.html', {root: './src'}); |
|
88 |
return false; |
|
89 |
} |
|
90 |
|
|
91 |
Zone.current.fork({ name: 'CSR fallback', onHandleError }).run(() => { |
|
92 |
res.render('index', { |
|
93 |
req, |
|
94 |
res, |
|
95 |
// time: true, // use this to determine what part of your app is slow only in development |
|
96 |
preboot: false, |
|
97 |
baseUrl: '/', |
|
98 |
requestUrl: req.originalUrl, |
|
99 |
originUrl: `http://localhost:${ app.get('port') }` |
|
100 |
}); |
|
88 | 101 |
}); |
102 |
|
|
89 | 103 |
} |
90 | 104 |
|
91 | 105 |
/** |
Also available in: Unified diff
Update to the lattest version of Angular Universal | create subfolders for deposit | use routerLinks in Nav bar and in browse view of main search