X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.ts;h=a7fea34da83d07599131f7f3d18968ef87a6db6a;hb=16f7022b06fb76c0b00c23c970bc8df605b0ec63;hp=0cb0759e0de9f5a4cd013cc28ef320ad68e56394;hpb=b229e38d50c43221b8fa21cf7c778212f2742e93;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index 0cb0759e0..a7fea34da 100644 --- a/server.ts +++ b/server.ts @@ -1,4 +1,6 @@ // FIXME: https://github.com/nodejs/node/pull/16853 +import { VideosCaptionCache } from './server/lib/cache/videos-caption-cache' + require('tls').DEFAULT_ECDH_CURVE = 'auto' import { isTestInstance } from './server/helpers/core-utils' @@ -84,22 +86,25 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch // ----------- App ----------- -// Enable CORS -app.use((req, res, next) => { - // These routes have already cors - if ( - req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && - req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 - ) { - return (cors({ - origin: '*', - exposedHeaders: 'Retry-After', - credentials: true - }))(req, res, next) - } - - return next() -}) +// Enable CORS for develop +if (isTestInstance()) { + app.use((req, res, next) => { + // These routes have already cors + if ( + req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && + req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 && + req.path.startsWith('/api/') === false + ) { + return (cors({ + origin: '*', + exposedHeaders: 'Retry-After', + credentials: true + }))(req, res, next) + } + + return next() + }) +} // For the logger app.use(morgan('combined', { @@ -178,6 +183,7 @@ async function startApplication () { // Caches initializations VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE) + VideosCaptionCache.Instance.init(CONFIG.CACHE.VIDEO_CAPTIONS.SIZE) // Enable Schedulers BadActorFollowScheduler.Instance.enable()