fix: register public thumbnail route before auth middleware — use router before authenticateToken
continuous-integration/webhook Deploy concluído (VPS4)
continuous-integration/webhook Deploy concluído (VPS4)
This commit is contained in:
@@ -588,9 +588,9 @@ app.use(checkInstallationMiddleware);
|
||||
// ROTAS PÚBLICAS (SEM AUTENTICAÇÃO)
|
||||
// ================================================================
|
||||
|
||||
// Endpoint público para servir thumbnails (sem autenticação)
|
||||
// Usado pelo frontend para carregar imagens sem bloquear o socket.io
|
||||
app.get('/api/images/:id/thumbnail', async (req, res) => {
|
||||
// Middleware que pula autenticação para rotas públicas de imagens
|
||||
const publicImageRoutes = express.Router();
|
||||
publicImageRoutes.get('/:id/thumbnail', async (req, res) => {
|
||||
try {
|
||||
const image = await db.get('SELECT thumb_filename, filename, client_name, patient_name FROM images WHERE id = $1', [req.params.id]);
|
||||
if (!image) return res.status(404).json({ error: 'Imagem não encontrada' });
|
||||
@@ -605,7 +605,6 @@ app.get('/api/images/:id/thumbnail', async (req, res) => {
|
||||
if (fsSync.existsSync(localPath)) {
|
||||
url = `/uploads/${fileToCheck}`;
|
||||
} else {
|
||||
// Se não existe localmente, tenta Wasabi
|
||||
try {
|
||||
const wasabiUrl = await storage.getImageUrl(fileToCheck, image.client_name, image.patient_name, false);
|
||||
url = wasabiUrl || `/uploads/${fileToCheck}`;
|
||||
@@ -620,6 +619,8 @@ app.get('/api/images/:id/thumbnail', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.use('/api/images', publicImageRoutes);
|
||||
|
||||
// ================================================================
|
||||
// ROTAS PROTEGIDAS (REQUEREM AUTENTICAÇÃO)
|
||||
// ================================================================
|
||||
|
||||
Reference in New Issue
Block a user