]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add cors for static paths too
authorChocobozzz <me@florianbigard.com>
Tue, 17 Jul 2018 13:04:54 +0000 (15:04 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 17 Jul 2018 13:04:54 +0000 (15:04 +0200)
server.ts
server/controllers/static.ts

index a688bb5d082a108ecee908a4366c1d2f39b690df..7dffb65761573a919c7ee7dfd99ac1dabc4d3e5f 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -114,22 +114,11 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
 
 // 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()
-  })
+  app.use(cors({
+    origin: '*',
+    exposedHeaders: 'Retry-After',
+    credentials: true
+  }))
 }
 
 // For the logger
index 679999859d70baf5bc95c73d939cefdafc003187..1600068e0c383edd99af184fab11da76cc9e3d96 100644 (file)
@@ -8,6 +8,8 @@ import { VideosCaptionCache } from '../lib/cache/videos-caption-cache'
 
 const staticRouter = express.Router()
 
+staticRouter.use(cors())
+
 /*
   Cors is very important to let other servers access torrent and video files
 */