Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-09-17 08:48:54 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-09-17 08:48:54 +0400
commita0e664fa10254109a64fe6aaef06cd4139a1ef7c (patch)
tree64db3585653006b050eb01b81a7e23492dd9dce7 /lib/server.js
parent61edbb1ff92ab18729f7f50754482ae5b2d2311a (diff)
add CORS header
this solves some issues with chromecast (see https://github.com/mafintosh/peerflix/pull/113)
Diffstat (limited to 'lib/server.js')
-rw-r--r--lib/server.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/server.js b/lib/server.js
index 3f85629..9809df7 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -15,6 +15,9 @@ module.exports = function Server (webtorrent, port) {
server.on('request', function (req, res) {
debug('onRequest')
+ if (req.headers.origin)
+ res.setHeader('access-control-allow-origin', req.headers.origin)
+
var u = url.parse(req.url)
if (u.pathname === '/favicon.ico') return res.end()
if (u.pathname === '/') u.pathname = '/' + webtorrent.index