diff options
Diffstat (limited to 'server/controllers/static.ts')
-rw-r--r-- | server/controllers/static.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index dc091455a..6ef9154b9 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -15,11 +15,17 @@ const staticRouter = express.Router() | |||
15 | // Cors is very important to let other servers access torrent and video files | 15 | // Cors is very important to let other servers access torrent and video files |
16 | staticRouter.use(cors()) | 16 | staticRouter.use(cors()) |
17 | 17 | ||
18 | // --------------------------------------------------------------------------- | ||
18 | // WebTorrent/Classic videos | 19 | // WebTorrent/Classic videos |
20 | // --------------------------------------------------------------------------- | ||
21 | |||
22 | const privateWebTorrentStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUIRE_AUTH === true | ||
23 | ? [ optionalAuthenticate, asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles) ] | ||
24 | : [] | ||
25 | |||
19 | staticRouter.use( | 26 | staticRouter.use( |
20 | STATIC_PATHS.PRIVATE_WEBSEED, | 27 | STATIC_PATHS.PRIVATE_WEBSEED, |
21 | optionalAuthenticate, | 28 | ...privateWebTorrentStaticMiddlewares, |
22 | asyncMiddleware(ensureCanAccessVideoPrivateWebTorrentFiles), | ||
23 | express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), | 29 | express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), |
24 | handleStaticError | 30 | handleStaticError |
25 | ) | 31 | ) |
@@ -35,11 +41,17 @@ staticRouter.use( | |||
35 | handleStaticError | 41 | handleStaticError |
36 | ) | 42 | ) |
37 | 43 | ||
44 | // --------------------------------------------------------------------------- | ||
38 | // HLS | 45 | // HLS |
46 | // --------------------------------------------------------------------------- | ||
47 | |||
48 | const privateHLSStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUIRE_AUTH === true | ||
49 | ? [ optionalAuthenticate, asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles) ] | ||
50 | : [] | ||
51 | |||
39 | staticRouter.use( | 52 | staticRouter.use( |
40 | STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, | 53 | STATIC_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS, |
41 | optionalAuthenticate, | 54 | ...privateHLSStaticMiddlewares, |
42 | asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles), | ||
43 | express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }), | 55 | express.static(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, { fallthrough: false }), |
44 | handleStaticError | 56 | handleStaticError |
45 | ) | 57 | ) |