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> | ||||
|     <TargetFramework>net9.0</TargetFramework> | ||||
|     <Nullable>enable</Nullable> | ||||
|     <ImplicitUsings>enable</ImplicitUsings> | ||||
|     <UserSecretsId>5a89fd49-e697-4d82-8374-f815ae04005d</UserSecretsId> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|   | ||||
| @@ -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(); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | ||||
|   | ||||
| @@ -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")] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user