Skip to content

Commit

Permalink
Enabled CORS for browserifying
Browse files Browse the repository at this point in the history
Layed the basis for making this module browserifyable by sending all
requests via corsproxy.com. Currently this is not yet possible because
of this issue in http-browserify:
browserify/http-browserify#35
  • Loading branch information
MaxGfeller committed Jan 29, 2014
1 parent 49837e6 commit f82d64a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ youtubeSearch.search = function(q, opts, cb) {
}
}

http.get(baseUrl + sanitizedQuery + optsString, function(res) {
http.get({
host: 'www.corsproxy.com',
path: '/gdata.youtube.com/feeds/api/videos?q=' + sanitizedQuery + optsString,
scheme: 'http',
headers: {
'GData-Version': '2',
'Access-Control-Allow-Credentials': 'false'
}
}, function(res) {
var responseString = '';
res.on('data', function(data) {
responseString += data;
Expand Down Expand Up @@ -51,7 +59,6 @@ youtubeSearch.search = function(q, opts, cb) {
});
});
}).on('error', function(e) {
console.log('error occured');
console.log(e);
});
}
Expand Down

0 comments on commit f82d64a

Please sign in to comment.