I have an application that makes a request for a JSON via axios. Follow the function
axios.get("http://localhost/teste.json")
.then((res) => {
this.setState({value: res.data.tgt.screenPosX})
}).catch((err) => {
console.log('Error')
})
But as the development server is running in 3000 I can not access this json on the apache server due to CORS policy
Requisição cross-origin bloqueada: A política de mesma origem (Same Origin Policy) impede a leitura do recurso remoto em http://localhost/teste.json. (Motivo: o cabeçalho CORS 'Access-Control-Allow-Origin' não está presente).
How can I solve this problem? How do I consume this JSON without going through CORS?
I do not know much about backend, but I need to solve the problem yesterday.
Thank you in advance !!