diff options
Diffstat (limited to 'server/controllers/client.js')
-rw-r--r-- | server/controllers/client.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/controllers/client.js b/server/controllers/client.js index 61e094980..572db6133 100644 --- a/server/controllers/client.js +++ b/server/controllers/client.js | |||
@@ -13,8 +13,9 @@ const Video = mongoose.model('Video') | |||
13 | const router = express.Router() | 13 | const router = express.Router() |
14 | 14 | ||
15 | const opengraphComment = '<!-- opengraph tags -->' | 15 | const opengraphComment = '<!-- opengraph tags -->' |
16 | const embedPath = path.join(__dirname, '../../client/dist/standalone/videos/embed.html') | 16 | const distPath = path.join(__dirname, '../../client/dist') |
17 | const indexPath = path.join(__dirname, '../../client/dist/index.html') | 17 | const embedPath = path.join(distPath, 'standalone/videos/embed.html') |
18 | const indexPath = path.join(distPath, 'index.html') | ||
18 | 19 | ||
19 | // Special route that add OpenGraph tags | 20 | // Special route that add OpenGraph tags |
20 | // Do not use a template engine for a so little thing | 21 | // Do not use a template engine for a so little thing |
@@ -24,6 +25,14 @@ router.use('/videos/embed', function (req, res, next) { | |||
24 | res.sendFile(embedPath) | 25 | res.sendFile(embedPath) |
25 | }) | 26 | }) |
26 | 27 | ||
28 | // Static HTML/CSS/JS client files | ||
29 | router.use('/client', express.static(distPath, { maxAge: constants.STATIC_MAX_AGE })) | ||
30 | |||
31 | // 404 for static files not found | ||
32 | router.use('/client/*', function (req, res, next) { | ||
33 | res.sendStatus(404) | ||
34 | }) | ||
35 | |||
27 | // --------------------------------------------------------------------------- | 36 | // --------------------------------------------------------------------------- |
28 | 37 | ||
29 | module.exports = router | 38 | module.exports = router |