Skip to content

Commit

Permalink
add CORS header
Browse files Browse the repository at this point in the history
this solves some issues with chromecast (see
mafintosh/peerflix#113)
  • Loading branch information
feross committed Sep 17, 2014
1 parent 61edbb1 commit a0e664f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0e664f

Please sign in to comment.