Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

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:

Insert CORS 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");

 

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de