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();'GET', '', 'false');
   //OauthRequest.setRequestHeader('Access-Control-Allow-Headers', 'Access-Control-Allow-Origin')
   //OauthRequest.setRequestHeader('Access-Control-Allow-Origin', 'null')

Related Questions