Skip to content

Commit f82d64a

Browse files
committed
Enabled CORS for browserifying
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
1 parent 49837e6 commit f82d64a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ youtubeSearch.search = function(q, opts, cb) {
1818
}
1919
}
2020

21-
http.get(baseUrl + sanitizedQuery + optsString, function(res) {
21+
http.get({
22+
host: 'www.corsproxy.com',
23+
path: '/gdata.youtube.com/feeds/api/videos?q=' + sanitizedQuery + optsString,
24+
scheme: 'http',
25+
headers: {
26+
'GData-Version': '2',
27+
'Access-Control-Allow-Credentials': 'false'
28+
}
29+
}, function(res) {
2230
var responseString = '';
2331
res.on('data', function(data) {
2432
responseString += data;
@@ -51,7 +59,6 @@ youtubeSearch.search = function(q, opts, cb) {
5159
});
5260
});
5361
}).on('error', function(e) {
54-
console.log('error occured');
5562
console.log(e);
5663
});
5764
}

0 commit comments

Comments
 (0)