open CORS to allow in-browser apps to communicate w/ PeerTube instances
authorWilliam Lahti <wilahti@gmail.com>
Thu, 28 Jun 2018 02:22:51 +0000 (19:22 -0700)
committerChocobozzz <me@florianbigard.com>
Fri, 29 Jun 2018 07:46:44 +0000 (09:46 +0200)
server.ts

index 5511c5435856fec72698f20295fa35e754d44267..adebd9ce90d64e9e9f78a4f50d9c7b5f4c79b331 100644 (file)
--- 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', {