I'm doing some basic javascript/html development on my MacOs and am requesting a API to populate some fields and I get the error below.
I'm running Server version: Apache/2.4.56 (Unix) as a web server.
Origin http://127.0.0.1 is not allowed by Access-Control-Allow-Origin. Status code: 200
JS to pull API and populate
function loadHITS() {
fetch(api_url)
.then((res) => res.json())
.then((data) => {
console.log(data);
document.getElementById('Count').innerHTML = data;
});
}
I've tried adding this in my httpd.conf file but its not solving the issue.
<Directory /var/www/html> ... Header set Access-Control-Allow-Origin "*" ...