Problem with CORS when using the API
Ricrdsson1 opened this issue · comments
Hello, I have a problem with CORS verification when using your API on my Web site. I added my WEB in your interface to enable CORS but it probably doesn't work.
var request = new XMLHttpRequest();
request.open('POST', 'https://api.trakt.tv/oauth/device/code');
request.setRequestHeader('Content-Type', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'client_id': 'xxx'
};
request.send(JSON.stringify(body));
Please try some code like this:
fetch('https://api.trakt.tv/oauth/device/code', {
'headers': { 'content-type': 'application/json' },
'referrer': 'https://yourdomain.com',
'body': '{"client_id":"X"}',
'method': 'POST'
});