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:
@@ -1,9 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>5a89fd49-e697-4d82-8374-f815ae04005d</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -14,13 +14,27 @@ builder.Services.AddDbContext<EleccionesDbContext>(options =>
|
|||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
// Configura CORS para permitir que tu frontend (y www.eldia.com) consuman la API.
|
// 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 =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
options.AddDefaultPolicy(policy =>
|
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
|
if (allowedOrigins.Any())
|
||||||
.AllowAnyHeader()
|
{
|
||||||
.AllowAnyMethod();
|
policy.WithOrigins(allowedOrigins)
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.AllowAnyMethod();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("5a89fd49-e697-4d82-8374-f815ae04005d")]
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Api")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Elecciones.Api")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[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.AssemblyProductAttribute("Elecciones.Api")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Api")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Elecciones.Api")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -4,10 +4,5 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"ElectoralApi": {
|
|
||||||
"BaseUrl": "https://api.eleccionesbonaerenses.gba.gob.ar",
|
|
||||||
"Username": "30500094156@elecciones2025.onmicrosoft.com",
|
|
||||||
"Password": "PTP847elec"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user