registration:1 Access to XMLHttpRequest at 'http://localhost:8080/api/User/register' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
builder.Services.AddCors(option => { option.AddPolicy("AllowMyOrigin", builder => { builder.WithOrigins("http://localhost:80"); //builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); }); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } //app.UseSwagger(); //app.UseSwaggerUI(); app.UseCors("AllowMyOrigin"); app.UseAuthorization(); app.MapControllers(); app.Run();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)