From 029b8973b3e88d0d40f37bb9e2b1be9990f7f4dd Mon Sep 17 00:00:00 2001 From: Marcos Date: Sun, 22 Mar 2026 12:45:49 -0300 Subject: [PATCH] Fix: Final Web UI image rendering logic --- templates/index.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index f9bad89..caa84c9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1041,8 +1041,14 @@ const panel = document.getElementById('insights-panel'); if (!panel) return; - // Injeta a senha web nas URLs das imagens para autenticação inline - const mdWithAuth = markdown.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path='); + // 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)})`; + }); + + // 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='); // Renderiza o Markdown para HTML usando marked.js panel.innerHTML = `
${marked.parse(mdWithAuth)}
`;