aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWilliam Lahti <wilahti@gmail.com>2018-06-27 19:22:51 -0700
committerChocobozzz <me@florianbigard.com>2018-06-29 09:46:44 +0200
commit1fd2d96ff81ffd433d10a489dd1796688c695014 (patch)
treed869a5d17628180811a282a36cac6c99f04bb771
parentfc0941cbec98ba80e73a596e5d889d80f86dbe6f (diff)
downloadPeerTube-1fd2d96ff81ffd433d10a489dd1796688c695014.tar.gz
PeerTube-1fd2d96ff81ffd433d10a489dd1796688c695014.tar.zst
PeerTube-1fd2d96ff81ffd433d10a489dd1796688c695014.zip
open CORS to allow in-browser apps to communicate w/ PeerTube instances
-rw-r--r--server.ts34
1 files changed, 16 insertions, 18 deletions
diff --git a/server.ts b/server.ts
index 5511c5435..adebd9ce9 100644
--- a/server.ts
+++ b/server.ts
@@ -84,24 +84,22 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
84 84
85// ----------- App ----------- 85// ----------- App -----------
86 86
87// Enable CORS for develop 87// Enable CORS
88if (isTestInstance()) { 88app.use((req, res, next) => {
89 app.use((req, res, next) => { 89 // These routes have already cors
90 // These routes have already cors 90 if (
91 if ( 91 req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 &&
92 req.path.indexOf(STATIC_PATHS.TORRENTS) === -1 && 92 req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
93 req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 93 ) {
94 ) { 94 return (cors({
95 return (cors({ 95 origin: '*',
96 origin: '*', 96 exposedHeaders: 'Retry-After',
97 exposedHeaders: 'Retry-After', 97 credentials: true
98 credentials: true 98 }))(req, res, next)
99 }))(req, res, next) 99 }
100 } 100
101 101 return next()
102 return next() 102});
103 })
104}
105 103
106// For the logger 104// For the logger
107app.use(morgan('combined', { 105app.use(morgan('combined', {