I’m creating a browser source for OBS that fetches a streamer’s followers, subs and chatters. My browser source works perfectly locally on the loopback address but I get CORS exception when loading the same browser source after pushing it to firebase.
I discovered that I was getting CORS error because tmi.twitch.tv does not allow a call to the https://tmi.twitch.tv/group/user/<channelName>/chatters
end point client side from a webpage.
Since tmi.twitch.tv is not intended for use by 3rd party devs it does not support CORS (access-control-allow-origin header) thus it cannot be accessed directly by a browser Javascript application. You will need to “proxy” the request through a server-side script if you need that data in Javascript. source
This is my block of code to fetch all the chatters for a given channel.
function getChatters(channelName) {
var settings = {
async: true,
crossDomain: true,
url: 'https://tmi.twitch.tv/group/user/' + channelName + '/chatters',
method: 'GET'
};
$.ajax(settings).done(function(response) {
$('p#chatters').prepend(response.chatters.viewers.join(', '));
$('p#moderators').prepend(response.chatters.moderators.join(', '));
});
}
Is there any way to get chatters via bearer token?
I use firebase + firestore.