aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'server.js')
-rw-r--r--server.js32
1 files changed, 9 insertions, 23 deletions
diff --git a/server.js b/server.js
index 5f474a196..72c2e7cd1 100644
--- a/server.js
+++ b/server.js
@@ -67,14 +67,16 @@ app.use(require('connect-livereload')({
67require('segfault-handler').registerHandler() 67require('segfault-handler').registerHandler()
68 68
69// Static files 69// Static files
70app.use(express.static(path.join(__dirname, '/app'), { maxAge: 0 })) 70app.use(express.static(path.join(__dirname, '/client'), { maxAge: 0 }))
71 71
72// API routes 72// API routes
73var api_route = '/api/' + constants.API_VERSION 73var api_route = '/api/' + constants.API_VERSION
74app.use(api_route, routes.api) 74app.use(api_route, routes.api)
75 75
76// Views routes 76// Client application
77app.use('/', routes.views) 77app.use('/*', function (req, res, next) {
78 res.sendFile(path.join(__dirname, 'client/index.html'))
79})
78 80
79// ----------- Tracker ----------- 81// ----------- Tracker -----------
80 82
@@ -108,26 +110,10 @@ app.use(function (req, res, next) {
108 next(err) 110 next(err)
109}) 111})
110 112
111// Prod : no stacktraces leaked to user 113app.use(function (err, req, res, next) {
112if (process.env.NODE_ENV === 'production') { 114 logger.error(err)
113 app.use(function (err, req, res, next) { 115 res.sendStatus(err.status || 500)
114 logger.error(err) 116})
115 res.status(err.status || 500)
116 res.render('error', {
117 message: err.message,
118 error: {}
119 })
120 })
121} else {
122 app.use(function (err, req, res, next) {
123 logger.error(err)
124 res.status(err.status || 500)
125 res.render('error', {
126 message: err.message,
127 error: err
128 })
129 })
130}
131 117
132// ----------- Create the certificates if they don't already exist ----------- 118// ----------- Create the certificates if they don't already exist -----------
133peertubeCrypto.createCertsIfNotExist(function (err) { 119peertubeCrypto.createCertsIfNotExist(function (err) {