Error: Access to XMLHttpRequest api from origin has been blocked by CORS policy No Access-Control-Allow-Origin header
Error in Google Chrome browser in einer Angular application
Access to XMLHttpRequest at 'https://localhost:44388/api/TimeRecords' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. |
Solution:
CORS eintragen in ASP.Net Core Startup.cs
In Asp.Net Core
Startup.cs at the Code Block:
1) ConfigureServices
//*allow Angular,React/Vue access to API services.AddCors(options => options.AddPolicy("AllowAccess_To_API ", policy => policy .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() )); |
2) Configure
//*Activate Access to Api from Angular, Vue, Clients app.UseCors("AllowAccess_To_API"); |