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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kiran MohantyRank #821 · 2.8K reputationPosted Feb 18, 2021, 5:33 AM EST
Rijwan AnsariRank #82 · 24.2K reputationPosted Feb 19, 2021, 11:26 AM EST
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")]Sachin SinghRank #66 · 26.2K reputationPosted Feb 19, 2021, 11:45 AM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 19, 2021, 10:46 PM EST