Linked Questions

Popular Questions

Preflight Options Request for Twitch Oauth2

Asked by At

I am attempting to do an Oauth Get request to Twitch and have included all the necessary parameters. However, I keep getting kicked back an error that says "Access to XMLHttpRequest at from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."I tried doing this by just adding the preflight request parameters as a request header but that didn't work. Thats commented out in the code below.

I thought that the browser automatically sent preflight 'OPTIONS' request? Is there a reason it is not doing so in this instance? If not, how do I make an OPTIONS request manually in my code.

document.body.onload = function() {
   OauthRequest = new XMLHttpRequest();
   OauthRequest.open('GET', 'https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=1i1ujqgeiucjbpfw38n0iv03f1j26j&redirect_uri=http://localhost&scope=viewing_activity_read&state=c3ab8aa609ea11e793ae92361f002671', 'false');
   //OauthRequest.setRequestHeader('Access-Control-Allow-Headers', 'Access-Control-Allow-Origin')
   //OauthRequest.setRequestHeader('Access-Control-Allow-Origin', 'null')
   OauthRequest.send()

Related Questions