]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/client.js
Server: move static/client routes in controllers/
[github/Chocobozzz/PeerTube.git] / server / controllers / client.js
index 61e0949803759932bd2eceacd808db8cb4fc4824..572db6133f99e6ce68f38e91913789559fafa2a5 100644 (file)
@@ -13,8 +13,9 @@ const Video = mongoose.model('Video')
 const router = express.Router()
 
 const opengraphComment = '<!-- opengraph tags -->'
-const embedPath = path.join(__dirname, '../../client/dist/standalone/videos/embed.html')
-const indexPath = path.join(__dirname, '../../client/dist/index.html')
+const distPath = path.join(__dirname, '../../client/dist')
+const embedPath = path.join(distPath, 'standalone/videos/embed.html')
+const indexPath = path.join(distPath, 'index.html')
 
 // Special route that add OpenGraph tags
 // Do not use a template engine for a so little thing
@@ -24,6 +25,14 @@ router.use('/videos/embed', function (req, res, next) {
   res.sendFile(embedPath)
 })
 
+// Static HTML/CSS/JS client files
+router.use('/client', express.static(distPath, { maxAge: constants.STATIC_MAX_AGE }))
+
+// 404 for static files not found
+router.use('/client/*', function (req, res, next) {
+  res.sendStatus(404)
+})
+
 // ---------------------------------------------------------------------------
 
 module.exports = router