Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Error: Access to XMLHttpRequest api from origin has been blocked by CORS policy No Access-Control-Allow-Origin header

22.01.2021 (👁492)

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