This commit is contained in:
2025-09-03 14:16:18 -03:00
parent 36a004a0b0
commit b8e6d33afa
3 changed files with 23 additions and 15 deletions

View File

@@ -27,8 +27,8 @@ FROM nginx:1.25-alpine
# al directorio por defecto donde Nginx sirve los archivos. # al directorio por defecto donde Nginx sirve los archivos.
COPY --from=build /app/dist /usr/share/nginx/html COPY --from=build /app/dist /usr/share/nginx/html
# Exponemos el puerto 80 (el puerto por defecto de Nginx). # Copiamos nuestra configuración de Nginx para manejar el enrutamiento de la SPA
EXPOSE 80 COPY frontend.nginx.conf /etc/nginx/conf.d/default.conf
# El comando por defecto de la imagen de Nginx ya es iniciar el servidor, # Exponemos el puerto 80 (el puerto por defecto de Nginx).
# así que no necesitamos un CMD o ENTRYPOINT. EXPOSE 80

View File

@@ -0,0 +1,18 @@
# frontend-admin/frontend.nginx.conf
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public";
}
}

View File

@@ -30,7 +30,7 @@
// 1. Obtener el manifest.json desde la ruta base detectada // 1. Obtener el manifest.json desde la ruta base detectada
const response = await fetch(`${WIDGETS_HOST}/manifest.json`); const response = await fetch(`${WIDGETS_HOST}/manifest.json`);
if (!response.ok) { if (!response.ok) {
throw new Error('No se pudo cargar el manifest de los widgets. (404 Not Found)'); throw new Error('No se pudo cargar el manifest. (404 Not Found)');
} }
const manifest = await response.json(); const manifest = await response.json();
@@ -53,20 +53,10 @@
// 4. Cargar el JS principal // 4. Cargar el JS principal
await loadScript(jsUrl); await loadScript(jsUrl);
// 5. El addEventListener ya no es necesario aquí, el consumidor lo añade.
// Si quiere que sea totalmente automático, puede añadirlo:
window.addEventListener('load', function () {
if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') {
window.EleccionesWidgets.render();
}
});
} catch (error) { } catch (error) {
console.error('Error al inicializar los widgets de Elecciones:', error); console.error('Error al inicializar los widgets de Elecciones:', error);
} }
} }
initWidgets(); initWidgets();
})(); })();