X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fstatic.ts;h=33c429eb17a235a1fed1adb52aa326bcbc3b992a;hb=b42c2c7e89a64ed730d8140840fe74a13c31f2a4;hp=7668ceb82c822bd400c844378afde40b7ed69d04;hpb=ea8107bff8e544594716a76d30ff372fc80d755c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 7668ceb82..33c429eb1 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,5 +1,6 @@ import cors from 'cors' import express from 'express' +import { handleStaticError } from '@server/middlewares' import { CONFIG } from '../initializers/config' import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers/constants' @@ -11,24 +12,28 @@ staticRouter.use(cors()) // Videos path for webseed staticRouter.use( STATIC_PATHS.WEBSEED, - express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }) // 404 because we don't have this video + express.static(CONFIG.STORAGE.VIDEOS_DIR, { fallthrough: false }), + handleStaticError ) staticRouter.use( STATIC_PATHS.REDUNDANCY, - express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }) // 404 because we don't have this video + express.static(CONFIG.STORAGE.REDUNDANCY_DIR, { fallthrough: false }), + handleStaticError ) // HLS staticRouter.use( STATIC_PATHS.STREAMING_PLAYLISTS.HLS, - express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }) // 404 if the file does not exist + express.static(HLS_STREAMING_PLAYLIST_DIRECTORY, { fallthrough: false }), + handleStaticError ) // Thumbnails path for express const thumbnailsPhysicalPath = CONFIG.STORAGE.THUMBNAILS_DIR staticRouter.use( STATIC_PATHS.THUMBNAILS, - express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE.SERVER, fallthrough: false }) // 404 if the file does not exist + express.static(thumbnailsPhysicalPath, { maxAge: STATIC_MAX_AGE.SERVER, fallthrough: false }), + handleStaticError ) // ---------------------------------------------------------------------------