Corrigindo ordem das rotas da API para evitar interceptação do app.get('*')
This commit is contained in:
@@ -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); });
|
||||||
@@ -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', () => {
|
app.listen(PORT, '0.0.0.0', () => {
|
||||||
console.log(`Servidor rodando na porta ${PORT}`);
|
console.log(`Servidor rodando na porta ${PORT}`);
|
||||||
initDatabase();
|
initDatabase();
|
||||||
|
|||||||
Reference in New Issue
Block a user