添加访问控制*

时间:2019-02-18 16:45:22

标签: javascript reactjs

尽管引用

Cross-Origin Read Blocking (CORB)

No 'Access-Control-Allow-Origin' - Node / Apache Port Issue

我在提出简单的get请求时仍然遇到问题。

我得到

  

从源访问“ https://github.com/”处的XMLHttpRequest   “ http://localhost:8001”已被CORS政策屏蔽:对   预检请求未通过访问控制检查:否   请求中存在“ Access-Control-Allow-Origin”标头   资源。

signGithub =  () => {
//    this.props.signWithGithub();

  Axios.get('https://github.com', {
      headers:{
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
      }
  }); // doesn't get link :(

  console.log('test');

};

<Chip
    label="Sign In with Github"
    clickable
    avatar={< Avatar alt = "Natacha" src = "https://avatars0.githubusercontent.com/u/9919?s=280&v=4" />}
    // href="http://localhost:8000/api/users/auth/github"
    onClick={this.signGithub}
    component="a"
    className={classes.chip}/>

0 个答案:

没有答案