Javascript 否';访问控制允许原点';发送post请求时,请求的资源上存在标头

Javascript 否';访问控制允许原点';发送post请求时,请求的资源上存在标头,javascript,html,iis,oauth-2.0,cors,Javascript,Html,Iis,Oauth 2.0,Cors,我尝试使用github oauth 2.0。由于我的网站没有后端,我使用XMLHttpRequest发送post请求,但在发送post请求以获取访问令牌时出现以下错误: Access to XMLHttpRequest at 'https://github.com/login/oauth/access_token' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-All

我尝试使用github oauth 2.0。由于我的网站没有后端,我使用XMLHttpRequest发送post请求,但在发送post请求以获取访问令牌时出现以下错误:

Access to XMLHttpRequest at 'https://github.com/login/oauth/access_token' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这是我的源代码

index.html

<a href="https://github.com/login/oauth/authorize?client_id=xxx&scope=user,public_repo">login</a>
login.html

<script src=functions.js></script>
<script>
var code=getQueryVariable("code");
console.log(code);
</script>
<script>
sendPost();
</script>

var代码=getQueryVariable(“代码”);
控制台日志(代码);
sendPost();

请快速阅读CORS

很可能。。您已启用CORS


我使用iis作为服务器。我还尝试将这些代码放到一个真正的域中,而不是本地主机。是否有通过代理请求的方法?但我无法设置响应的属性。我怀疑OP拥有github服务器,因此OP无法启用CORS
<script src=functions.js></script>
<script>
var code=getQueryVariable("code");
console.log(code);
</script>
<script>
sendPost();
</script>