I'm working on an Angular application but when I call my local API I have this error
Failed to load https://localhost:44358/api/try: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
And I have also this :
ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …} error : ProgressEvent
So I saw some solutions and I try this on my .Net Core API in the startup file
services.AddCors(options =>
{
options.AddPolicy("AnyOrigin", builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});
But I have the same error ... Can I have some help ?
Finally it work, I think I forget to build my .Net Core API