]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.ts
Upgrade sequelize
[github/Chocobozzz/PeerTube.git] / server.ts
index 1ba208c280b38ffc3940044387074b3d19530724..9c74ddb694024a77b9332824760e05205feb64c8 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -26,7 +26,7 @@ const app = express()
 // ----------- Database -----------
 // Do not use barrels because we don't want to load all modules here (we need to initialize database first)
 import { logger } from './server/helpers/logger'
-import { API_VERSION, CONFIG } from './server/initializers/constants'
+import { API_VERSION, CONFIG, STATIC_PATHS } from './server/initializers/constants'
 // Initialize database and models
 import { database as db } from './server/initializers/database'
 db.init(false).then(() => onDatabaseInitDone())
@@ -57,10 +57,20 @@ import { apiRouter, clientsRouter, staticRouter } from './server/controllers'
 
 // Enable CORS for develop
 if (isTestInstance()) {
-  app.use(cors({
-    origin: 'http://localhost:3000',
-    credentials: true
-  }))
+  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: 'http://localhost:3000',
+        credentials: true
+      }))(req, res, next)
+    }
+
+    return next()
+  })
 }
 
 // For the logger
@@ -150,7 +160,7 @@ function onDatabaseInitDone () {
         VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE)
 
         logger.info('Server listening on port %d', port)
-        logger.info('Webserver: %s', CONFIG.WEBSERVER.URL)
+        logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
       })
     })
 }