CORS issue while loading in React Frontend
wdpoppe opened this issue · 1 comments
First of all, thank you for this node.js based API of ErgastAPI.
I'm successfully running the API in Docker using domain localhost:8080
Unfortunately the REST API is blocked by CORS while loading it in my react app.
Exact error is:
VM1514:1 Access to XMLHttpRequest at 'localhost:8080/drivers' from origin 'http://localhost:3000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
This is my code so far. I've already tried to add CORS header but that doesn't effect anything.
Can you please help me out a bit?
function App() {
useEffect(() => {
let ignore = false;
async function fetchData() {
const result = await axios("localhost:8080/drivers", {
headers: {
"Access-Control-Allow-Origin": "*"
}
});
if (!ignore) setData(result.data);
console.log(result);
}
fetchData();
});
}
First of all, I apologize for not replying to you immediately. I inform you that I am no longer keeping this project. You can get the data from this site Ergast.com