Access to XMLHttpRequest at 'http://localhost:8080/api/photos/%7B_id%7D' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Feb 20, 2021, 3:46 AM
Sachin SinghPosted Feb 19, 2021, 4:45 PM
Rijwan AnsariPosted Feb 19, 2021, 4:26 PM
Only for .NET Core Web API project, add following changes:
services.AddMvc()line in theConfigureServices()method of the Startup.cs file:services.AddCors(allowsites=>{allowsites.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); });app.UseMvc()line in theConfigure()method of the Startup.cs file:app.UseCors(options => options.AllowAnyOrigin());[EnableCors("AllowOrigin")]Kiran MohantyPosted Feb 18, 2021, 10:33 AM