fix: isola helpers de UI para evitar vazamento de SDK de backend e corrige tela branca

This commit is contained in:
Sidney 2026-04-22 09:47:58 -03:00
parent b11ce359a6
commit 52d00343fa
6 changed files with 20 additions and 3 deletions

View File

@ -26,3 +26,4 @@
4. **Upload de Arquivos:** Proibido o uso de Base64 para envio de novos arquivos ao servidor. Use obrigatoriamente `FormData` e envie o objeto `File/Blob` para as rotas de API que integram com o MinIO.
5. **Build & Deploy Stability:** O pipeline de deploy deve obrigatoriamente utilizar `runs-on: self-hosted` e compilar apenas a plataforma `linux/arm64` (sem emulação QEMU). A atualização da stack em produção deve ser automatizada via container transiente do Watchtower.
6. **Express Compatibility**: Avoid using raw `/*` wildcards in Express 5 routes; use Regex paths (`/^\/route\/(.+)$/`) for compatibility with `path-to-regexp` v8.
7. **Frontend Independence**: NEVER import files from `services/` or `server.js` directly into React components to prevent Node.js/SDK leakage (causes White Screen). Use `helpers.ts` for UI logic.

View File

@ -11,6 +11,7 @@
- [x] Correção do Crash 404 no Portal: Injeção da pasta `src/services` no container de produção para permitir o import do `storage.js`.
- [x] Correção das Imagens de Prova: Normalização das URLs nas questões de avaliações (Portal e Manager).
- [x] Estabilização de CI/CD: Transição para `runs-on: self-hosted` (ARM64 nativo) eliminando lentidão e crashes do QEMU.
- [x] Fix Tela Branca (Portal): Refatoração de `normalizePhotoUrl` para `helpers.ts` isolado, evitando vazamento de SDK de Backend no Navegador.
- [ ] Próximo Passo: Verificar se o Watchtower sincronizou as imagens corretamente na produção.
### 💳 Módulo Financeiro (Portal do Aluno)

View File

@ -3,7 +3,7 @@ import { useTheme } from '../context/ThemeContext';
import { Moon, Sun } from 'lucide-react';
import { useLocation } from 'react-router-dom';
import Notifications from './Notifications';
import { normalizePhotoUrl } from '../services/storage';
import { normalizePhotoUrl } from '../helpers';
const pageTitles: Record<string, string> = {
'/': 'Dashboard',

View File

@ -5,7 +5,7 @@ import {
FileText, Award, User, LogOut, GraduationCap, X, Menu, ClipboardList
} from 'lucide-react';
import { useState, useEffect } from 'react';
import { normalizePhotoUrl } from '../services/storage';
import { normalizePhotoUrl } from '../helpers';
const navItems = [
{ path: '/', label: 'Dashboard', icon: LayoutDashboard },

15
portal/src/helpers.ts Normal file
View File

@ -0,0 +1,15 @@
/**
* Helpers compartihados de UI
*/
export function normalizePhotoUrl(url) {
if (!url || typeof url !== 'string') return '';
if (url.startsWith('data:image')) return url;
if (url.startsWith('/storage/')) return url;
try {
const match = url.match(/^https?:\/\/[^\/]+\/(.+)$/);
if (match) return `/storage/${match[1]}`;
} catch(e) {}
return url;
}

View File

@ -5,7 +5,7 @@ import {
ClipboardList, Clock, ChevronLeft, ChevronRight, Send, CheckCircle2,
XCircle, Award, AlertTriangle, Timer, ArrowLeft
} from 'lucide-react';
import { normalizePhotoUrl } from '../services/storage';
import { normalizePhotoUrl } from '../helpers';
// ==========================================
// Exam Environment — Portal do Aluno