diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-22 14:15:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-22 14:15:23 +0100 |
commit | 78967fca4cacbc247fa6fb62d64b2d6825a10804 (patch) | |
tree | f063a82b0658005e3d5ce23648333805782155ed /server/controllers/client.ts | |
parent | 93df58cc4865af9046d2b31e03fa37d3ae54e45b (diff) | |
download | PeerTube-78967fca4cacbc247fa6fb62d64b2d6825a10804.tar.gz PeerTube-78967fca4cacbc247fa6fb62d64b2d6825a10804.tar.zst PeerTube-78967fca4cacbc247fa6fb62d64b2d6825a10804.zip |
Register service worker
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r-- | server/controllers/client.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index f5124c55b..2fcca6f76 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -11,8 +11,6 @@ const clientsRouter = express.Router() | |||
11 | 11 | ||
12 | const distPath = join(root(), 'client', 'dist') | 12 | const distPath = join(root(), 'client', 'dist') |
13 | const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images') | 13 | const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images') |
14 | const manifestPath = join(root(), 'client', 'dist', 'manifest.json') | ||
15 | const serviceWorkerPath = join(root(), 'client', 'dist', 'ngsw-worker.js') | ||
16 | const embedPath = join(distPath, 'standalone', 'videos', 'embed.html') | 14 | const embedPath = join(distPath, 'standalone', 'videos', 'embed.html') |
17 | const indexPath = join(distPath, 'index.html') | 15 | const indexPath = join(distPath, 'index.html') |
18 | 16 | ||
@@ -27,8 +25,17 @@ clientsRouter.use('/videos/embed', (req: express.Request, res: express.Response, | |||
27 | }) | 25 | }) |
28 | 26 | ||
29 | // Static HTML/CSS/JS client files | 27 | // Static HTML/CSS/JS client files |
30 | clientsRouter.use('/manifest.json', express.static(manifestPath, { maxAge: STATIC_MAX_AGE })) | 28 | |
31 | clientsRouter.use('/ngsw-worker.js', express.static(serviceWorkerPath, { maxAge: STATIC_MAX_AGE })) | 29 | const staticClientFiles = [ |
30 | 'manifest.json', | ||
31 | 'ngsw-worker.js', | ||
32 | 'ngsw.json' | ||
33 | ] | ||
34 | for (const staticClientFile of staticClientFiles) { | ||
35 | const path = join(root(), 'client', 'dist', staticClientFile) | ||
36 | clientsRouter.use('/' + staticClientFile, express.static(path, { maxAge: STATIC_MAX_AGE })) | ||
37 | } | ||
38 | |||
32 | clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE })) | 39 | clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE })) |
33 | clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE })) | 40 | clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE })) |
34 | 41 | ||