Corrigindo ordem das rotas da API para evitar interceptação do app.get('*')

This commit is contained in:
2026-06-07 23:05:55 +00:00
parent 02d0c6fb86
commit 805254f838
2 changed files with 11 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
require('dotenv').config();
const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
pool.query('SELECT * FROM escola.turmas;')
.then(res => { console.log("Turmas:", res.rows); process.exit(0); })
.catch(e => { console.error("Erro:", e.message); process.exit(1); });
+5 -4
View File
@@ -4566,10 +4566,6 @@ app.post('/api/chat', requireAuth, async (req, res) => {
}
});
// Rota coringa para redirecionar para index.html
app.get('*', requireAuth, (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// ============================================================
@@ -4689,6 +4685,11 @@ app.delete('/api/alunos/:id', requireAuth, async (req, res) => {
}
});
// Rota coringa para redirecionar para index.html
app.get('*', requireAuth, (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Servidor rodando na porta ${PORT}`);
initDatabase();