I have an .net core api controller setup and have used enabled cors as follows in the startup class:
In my configureServices function I've done the following:
service.AddCors(c =>
{
c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin());
{
And in my configure function I've done: app.useCors();
On my client app I'm doing the following:
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: new Headers({
'Content-Type': 'application/json'
}).then.....
When I make my call from the client I get the following error:
Access to fetch at 'http://...' from origin 'http://...' has been blocked by CORS policy: response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves you needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
My api post works using postman.
How can I get this to work from my client?