Actualmente estoy desarrollando una API en. Net Core 3, la cual tengo configurado los cors asi:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using WebApiSoporte.Entities;
namespace WebApiSoporte
{
public class Startup
{
readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<UrlJBancos>(Configuration.GetSection("UrlJBancos"));
services.Configure<UrlsConexion>(Configuration.GetSection("ConnectionStrings"));
services.Configure<UrlsMenuBanco>(Configuration.GetSection("MenuBancos"));
services.Configure<UrlActividades>(Configuration.GetSection("Actvidades"));
services.AddCors(options =>
{
options.AddPolicy(name: MyAllowSpecificOrigins,
builder =>
{
builder.WithOrigins("http://localhost:8100",
"https://localhost:44355",
"https://localhost:81",
"http://192.168.0.10",
"http://prestopopular.cibergestion.com:90",
"capacitor://localhost",
"http://localhost").AllowAnyHeader();
});
});
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors(MyAllowSpecificOrigins);
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
ademas, estoy construyendo una application en ionic 5, angular 10, la cual consume esta API, al momento de hacer pruebas en ionic serve lab la app funciona correctamente, pero al hacer la prueba con android studio o un publicando mi api en otro servidor me arroja el siguiente error:
quisiera por favor que alguien me ayudara ya que debo consumir la api en producciona la cual no he podido.