From 50c385796c6763ed96ee92d05a85b2612d6b3986 Mon Sep 17 00:00:00 2001 From: dmolinari Date: Thu, 14 Aug 2025 15:51:19 -0300 Subject: [PATCH] Feat: Variables de entorno y .env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Se elimina configuración sensible y específica de los configs. Se añaden variables de entorno y un archivo .env --- .../src/Elecciones.Api/Elecciones.Api.csproj | 3 ++- Elecciones-Web/src/Elecciones.Api/Program.cs | 20 ++++++++++++++++--- .../net9.0/Elecciones.Api.AssemblyInfo.cs | 3 ++- .../src/Elecciones.Worker/appsettings.json | 5 ----- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj index 7a16bfa..dadefab 100644 --- a/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj +++ b/Elecciones-Web/src/Elecciones.Api/Elecciones.Api.csproj @@ -1,9 +1,10 @@ - + net9.0 enable enable + 5a89fd49-e697-4d82-8374-f815ae04005d diff --git a/Elecciones-Web/src/Elecciones.Api/Program.cs b/Elecciones-Web/src/Elecciones.Api/Program.cs index 1bce2f9..dc38701 100644 --- a/Elecciones-Web/src/Elecciones.Api/Program.cs +++ b/Elecciones-Web/src/Elecciones.Api/Program.cs @@ -14,13 +14,27 @@ builder.Services.AddDbContext(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(); + } }); }); diff --git a/Elecciones-Web/src/Elecciones.Api/obj/Debug/net9.0/Elecciones.Api.AssemblyInfo.cs b/Elecciones-Web/src/Elecciones.Api/obj/Debug/net9.0/Elecciones.Api.AssemblyInfo.cs index 740d68d..e384e44 100644 --- a/Elecciones-Web/src/Elecciones.Api/obj/Debug/net9.0/Elecciones.Api.AssemblyInfo.cs +++ b/Elecciones-Web/src/Elecciones.Api/obj/Debug/net9.0/Elecciones.Api.AssemblyInfo.cs @@ -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")] diff --git a/Elecciones-Web/src/Elecciones.Worker/appsettings.json b/Elecciones-Web/src/Elecciones.Worker/appsettings.json index 18fb995..07c8e4c 100644 --- a/Elecciones-Web/src/Elecciones.Worker/appsettings.json +++ b/Elecciones-Web/src/Elecciones.Worker/appsettings.json @@ -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" } } \ No newline at end of file