diff options
-rw-r--r-- | server.ts | 34 | ||||
-rw-r--r-- | server/controllers/api/index.ts | 7 |
2 files changed, 25 insertions, 16 deletions
@@ -84,22 +84,24 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch | |||
84 | 84 | ||
85 | // ----------- App ----------- | 85 | // ----------- App ----------- |
86 | 86 | ||
87 | // Enable CORS | 87 | // Enable CORS for develop |
88 | app.use((req, res, next) => { | 88 | if (isTestInstance()) { |
89 | // These routes have already cors | 89 | app.use((req, res, next) => { |
90 | if ( | 90 | // These routes have already cors |
91 | req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && | 91 | if ( |
92 | req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 | 92 | req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && |
93 | ) { | 93 | req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 |
94 | return (cors({ | 94 | ) { |
95 | origin: '*', | 95 | return (cors({ |
96 | exposedHeaders: 'Retry-After', | 96 | origin: '*', |
97 | credentials: true | 97 | exposedHeaders: 'Retry-After', |
98 | }))(req, res, next) | 98 | credentials: true |
99 | } | 99 | }))(req, res, next) |
100 | 100 | } | |
101 | return next() | 101 | |
102 | }) | 102 | return next() |
103 | }) | ||
104 | } | ||
103 | 105 | ||
104 | // For the logger | 106 | // For the logger |
105 | app.use(morgan('combined', { | 107 | app.use(morgan('combined', { |
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 8f63b9535..c386a6710 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts | |||
@@ -8,9 +8,16 @@ import { accountsRouter } from './accounts' | |||
8 | import { videosRouter } from './videos' | 8 | import { videosRouter } from './videos' |
9 | import { badRequest } from '../../helpers/express-utils' | 9 | import { badRequest } from '../../helpers/express-utils' |
10 | import { videoChannelRouter } from './video-channel' | 10 | import { videoChannelRouter } from './video-channel' |
11 | import * as cors from 'cors' | ||
11 | 12 | ||
12 | const apiRouter = express.Router() | 13 | const apiRouter = express.Router() |
13 | 14 | ||
15 | apiRouter.use(cors({ | ||
16 | origin: '*', | ||
17 | exposedHeaders: 'Retry-After', | ||
18 | credentials: true | ||
19 | })) | ||
20 | |||
14 | apiRouter.use('/server', serverRouter) | 21 | apiRouter.use('/server', serverRouter) |
15 | apiRouter.use('/oauth-clients', oauthClientsRouter) | 22 | apiRouter.use('/oauth-clients', oauthClientsRouter) |
16 | apiRouter.use('/config', configRouter) | 23 | apiRouter.use('/config', configRouter) |