I'm trying to set Access-Control-Allow-Origin to be able to skip the following error:
XMLHttpRequest cannot load http://www.test.dev:8090/glasses/import/log/qa/qa2/20170106?headers%5BAc…llow-Headers%5D=Origin%2C%20X-Requested-With%2C%20Content-Type%2C%20Accept. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.test.dev:3000' is therefore not allowed access.
But I'm not getting the desired result. The client side is implemented in reactjs and send a get request to a python web app. Here is my code:
class InfoBox extends Component {
constructor() {
super();
this.state = {items:[]};
}
componentDidMount() {
Request.get('http://www.test.dev:8090/glasses/import/log/qa/qa2/20170106', {
headers:{
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
}
})
.then((response) => {
this.setState({items:response});
});
}
render() {
const content = this.state.items.map(function(item) {return <div>{item}</div>});
return (
<div >{content}</div>
);
}
}