diff options
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -67,14 +67,16 @@ app.use(require('connect-livereload')({ | |||
67 | require('segfault-handler').registerHandler() | 67 | require('segfault-handler').registerHandler() |
68 | 68 | ||
69 | // Static files | 69 | // Static files |
70 | app.use(express.static(path.join(__dirname, '/app'), { maxAge: 0 })) | 70 | app.use(express.static(path.join(__dirname, '/client'), { maxAge: 0 })) |
71 | 71 | ||
72 | // API routes | 72 | // API routes |
73 | var api_route = '/api/' + constants.API_VERSION | 73 | var api_route = '/api/' + constants.API_VERSION |
74 | app.use(api_route, routes.api) | 74 | app.use(api_route, routes.api) |
75 | 75 | ||
76 | // Views routes | 76 | // Client application |
77 | app.use('/', routes.views) | 77 | app.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 | 113 | app.use(function (err, req, res, next) { |
112 | if (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 ----------- |
133 | peertubeCrypto.createCertsIfNotExist(function (err) { | 119 | peertubeCrypto.createCertsIfNotExist(function (err) { |