I'm using Angular
in frontend and C#
as my backend, I got this error when I try to edit fields and save it:
Access to XMLHttpRequest at 'http://192.168.220.14:81/api/registry' from origin 'http://artc.tj' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
PUT http://192.168.220.14:81/api/reg polyfills-es2015.23e79c711e3c227d781f.js:1 PUT http://192.168.220.14:81/api/registry net::ERR_FAILED
Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
//CORS
services.AddCors(options =>
{
options.AddPolicy(MyAllowSpecificOrigins,
builder =>
{
builder.WithOrigins("http://localhost",
"http://localhost:4200",
"http://artc.tj",
"http://192.168.220.14")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});
}