From 3cfb6fb3d2bfa8980460b8f8167d28d4e5cfb5af Mon Sep 17 00:00:00 2001 From: Marcos Date: Sun, 22 Mar 2026 12:58:11 -0300 Subject: [PATCH] Fix: Robust web password handling for insight images --- templates/index.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index caa84c9..e50e204 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1041,14 +1041,17 @@ const panel = document.getElementById('insights-panel'); if (!panel) return; + // Garante que temos a senha (tenta pegar do global ou do localStorage se precisar) + const activePwd = webPassword || localStorage.getItem('vps_web_password') || ''; + // Transforma caminhos da VPS (![alt](/host_root/...) em links da nossa API segura // Ex: /host_root/root/img.jpg -> /api/host_file?pwd=...&path=/host_root/root/img.jpg let mdWithAuth = markdown.replace(/!\[(.*?)\]\((\/host_root\/.*?)\)/g, (match, alt, path) => { - return `![${alt}](/api/host_file?pwd=${encodeURIComponent(webPassword)}&path=${encodeURIComponent(path)})`; + return `![${alt}](/api/host_file?pwd=${encodeURIComponent(activePwd)}&path=${encodeURIComponent(path)})`; }); // Fallback para qualquer outro caso que tenha sobrado do prefixo antigo - mdWithAuth = mdWithAuth.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path='); + mdWithAuth = mdWithAuth.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(activePwd) + '&path='); // Renderiza o Markdown para HTML usando marked.js panel.innerHTML = `
${marked.parse(mdWithAuth)}
`;