aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/server.ts b/server.ts
index 1ba208c28..2effa9340 100644
--- a/server.ts
+++ b/server.ts
@@ -26,7 +26,7 @@ const app = express()
26// ----------- Database ----------- 26// ----------- Database -----------
27// Do not use barrels because we don't want to load all modules here (we need to initialize database first) 27// Do not use barrels because we don't want to load all modules here (we need to initialize database first)
28import { logger } from './server/helpers/logger' 28import { logger } from './server/helpers/logger'
29import { API_VERSION, CONFIG } from './server/initializers/constants' 29import { API_VERSION, CONFIG, STATIC_PATHS } from './server/initializers/constants'
30// Initialize database and models 30// Initialize database and models
31import { database as db } from './server/initializers/database' 31import { database as db } from './server/initializers/database'
32db.init(false).then(() => onDatabaseInitDone()) 32db.init(false).then(() => onDatabaseInitDone())
@@ -57,10 +57,20 @@ import { apiRouter, clientsRouter, staticRouter } from './server/controllers'
57 57
58// Enable CORS for develop 58// Enable CORS for develop
59if (isTestInstance()) { 59if (isTestInstance()) {
60 app.use(cors({ 60 app.use((req, res, next) => {
61 origin: 'http://localhost:3000', 61 // These routes have already cors
62 credentials: true 62 if (
63 })) 63 req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
64 req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
65 ) {
66 return (cors({
67 origin: 'http://localhost:3000',
68 credentials: true
69 }))(req, res, next)
70 }
71
72 return next()
73 })
64} 74}
65 75
66// For the logger 76// For the logger