From: William Lahti Date: Thu, 28 Jun 2018 02:22:51 +0000 (-0700) Subject: open CORS to allow in-browser apps to communicate w/ PeerTube instances X-Git-Tag: v1.0.0-beta.10.pre.1~114 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1fd2d96ff81ffd433d10a489dd1796688c695014;p=oweals%2Fpeertube.git open CORS to allow in-browser apps to communicate w/ PeerTube instances --- diff --git a/server.ts b/server.ts index 5511c5435..adebd9ce9 100644 --- a/server.ts +++ b/server.ts @@ -84,24 +84,22 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch // ----------- App ----------- -// 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 - ) { - return (cors({ - origin: '*', - exposedHeaders: 'Retry-After', - credentials: true - }))(req, res, next) - } - - return next() - }) -} +// 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() +}); // For the logger app.use(morgan('combined', {