Feat: Variables de entorno y .env

- Se elimina configuración sensible y específica de los configs. Se añaden variables de entorno y un archivo .env
This commit is contained in:
2025-08-14 15:51:19 -03:00
parent 1d58023113
commit 50c385796c
4 changed files with 21 additions and 10 deletions

View File

@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>5a89fd49-e697-4d82-8374-f815ae04005d</UserSecretsId>
</PropertyGroup>
<ItemGroup>

View File

@@ -14,13 +14,27 @@ builder.Services.AddDbContext<EleccionesDbContext>(options =>
builder.Services.AddControllers();
// Configura CORS para permitir que tu frontend (y www.eldia.com) consuman la API.
// builder.Services.AddCors(options =>
// {
// options.AddDefaultPolicy(policy =>
// {
// policy.WithOrigins("http://localhost:5173", "http://localhost:8600", "http://www.eldia.com", "http://elecciones2025.eldia.com")
// .AllowAnyHeader()
// .AllowAnyMethod();
// });
// });
var allowedOrigins = builder.Configuration["AllowedOrigins"]?.Split(',') ?? [];
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5173", "http://localhost:8600", "http://www.eldia.com", "http://elecciones2025.eldia.com") // Añade aquí los dominios que necesites
.AllowAnyHeader()
.AllowAnyMethod();
if (allowedOrigins.Any())
{
policy.WithOrigins(allowedOrigins)
.AllowAnyHeader()
.AllowAnyMethod();
}
});
});

View File

@@ -10,10 +10,11 @@
using System;
using System.Reflection;
[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("5a89fd49-e697-4d82-8374-f815ae04005d")]
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b90baadeedb870b5b1c9eeeb7022a0d211b61bec")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1d580231134cc923bf8cbc524140ceb0ae88752f")]
[assembly: System.Reflection.AssemblyProductAttribute("Elecciones.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -4,10 +4,5 @@
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ElectoralApi": {
"BaseUrl": "https://api.eleccionesbonaerenses.gba.gob.ar",
"Username": "30500094156@elecciones2025.onmicrosoft.com",
"Password": "PTP847elec"
}
}