Now, I am trying to make a fetch API call to a server. Something like
const response = fetch(request, {
method: 'GET',
mode: 'cors',
headers: {
// "Content-Type": "application/json;charset=utf-8"
// "Access-Control-Allow-Origin": "*"
}
})
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error));
so the network call goes through and I get a 200 response but it gives me the error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
on my console and
TypeError: Failed to fetch
.
So just to test a fix for this really quick I tried to add the ACAO header (uncommenting the headers I have) but that sends an OPTIONS request which give a 405 (method not allowed) response AND the exact same errors as previously.
If someone could help with this I would love you forever, thanks.