// ----------- App -----------
-// 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()
-})
+// 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()
+ })
+}
// For the logger
app.use(morgan('combined', {
import { videosRouter } from './videos'
import { badRequest } from '../../helpers/express-utils'
import { videoChannelRouter } from './video-channel'
+import * as cors from 'cors'
const apiRouter = express.Router()
+apiRouter.use(cors({
+ origin: '*',
+ exposedHeaders: 'Retry-After',
+ credentials: true
+}))
+
apiRouter.use('/server', serverRouter)
apiRouter.use('/oauth-clients', oauthClientsRouter)
apiRouter.use('/config', configRouter)