diff --git a/.gitignore b/.gitignore index 3d457d9..cc0666d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,6 @@ lerna-debug.log* # Variables de entorno # ------------------------------- -# Nunca subas tus claves de API, contraseñas de BD, etc. -# Crea un archivo .env.example con las variables vacías para guiar a otros desarrolladores. -.env .env.local .env.development.local .env.test.local diff --git a/Backend/GestionIntegral.Api/.env b/Backend/GestionIntegral.Api/.env new file mode 100644 index 0000000..aab9c6b --- /dev/null +++ b/Backend/GestionIntegral.Api/.env @@ -0,0 +1,12 @@ +# ================================================ +# VARIABLES DE ENTORNO PARA LA CONFIGURACIÓN DE CORREO +# ================================================ +# El separador de doble guion bajo (__) se usa para mapear la jerarquía del JSON. +# MailSettings:SmtpHost se convierte en MailSettings__SmtpHost + +MailSettings__SmtpHost="mail.eldia.com" +MailSettings__SmtpPort=587 +MailSettings__SenderName="Club - Diario El Día" +MailSettings__SenderEmail="alertas@eldia.com" +MailSettings__SmtpUser="alertas@eldia.com" +MailSettings__SmtpPass="@Alertas713550@" \ No newline at end of file diff --git a/Backend/GestionIntegral.Api/GestionIntegral.Api.csproj b/Backend/GestionIntegral.Api/GestionIntegral.Api.csproj index 808f888..4042988 100644 --- a/Backend/GestionIntegral.Api/GestionIntegral.Api.csproj +++ b/Backend/GestionIntegral.Api/GestionIntegral.Api.csproj @@ -9,6 +9,7 @@ + diff --git a/Backend/GestionIntegral.Api/Program.cs b/Backend/GestionIntegral.Api/Program.cs index 064ad81..0ec1aaa 100644 --- a/Backend/GestionIntegral.Api/Program.cs +++ b/Backend/GestionIntegral.Api/Program.cs @@ -24,6 +24,10 @@ using GestionIntegral.Api.Models.Comunicaciones; using GestionIntegral.Api.Services.Comunicaciones; using GestionIntegral.Api.Data.Repositories.Comunicaciones; +// Carga las variables de entorno desde el archivo .env al inicio de la aplicación. +// Debe ser la primera línea para que la configuración esté disponible para el 'builder'. +DotNetEnv.Env.Load(); + var builder = WebApplication.CreateBuilder(args); // --- Registros de Servicios --- diff --git a/Backend/GestionIntegral.Api/appsettings.json b/Backend/GestionIntegral.Api/appsettings.json index ad27f49..2748571 100644 --- a/Backend/GestionIntegral.Api/appsettings.json +++ b/Backend/GestionIntegral.Api/appsettings.json @@ -16,11 +16,11 @@ }, "AllowedHosts": "*", "MailSettings": { - "SmtpHost": "mail.eldia.com", - "SmtpPort": 587, - "SenderName": "Club - Diario El Día", - "SenderEmail": "alertas@eldia.com", - "SmtpUser": "alertas@eldia.com", - "SmtpPass": "@Alertas713550@" -} + "SmtpHost": "", + "SmtpPort": 0, + "SenderName": "", + "SenderEmail": "", + "SmtpUser": "", + "SmtpPass": "" + } } \ No newline at end of file