From 805254f8384be3109313cbf76134eb7ae4d0f218 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Sun, 7 Jun 2026 23:05:55 +0000 Subject: [PATCH] =?UTF-8?q?Corrigindo=20ordem=20das=20rotas=20da=20API=20p?= =?UTF-8?q?ara=20evitar=20intercepta=C3=A7=C3=A3o=20do=20app.get('*')?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check_db.js | 6 ++++++ server.js | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 check_db.js diff --git a/check_db.js b/check_db.js new file mode 100644 index 0000000..72de611 --- /dev/null +++ b/check_db.js @@ -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); }); diff --git a/server.js b/server.js index 76dc44b..466a47d 100644 --- a/server.js +++ b/server.js @@ -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();