fix: replace Express 5 incompatible optional param (:slug?) with two explicit routes
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 2m0s
Details
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 2m0s
Details
This commit is contained in:
parent
5870ac8788
commit
f927b85dc6
|
|
@ -2993,9 +2993,9 @@ async function startServer() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Página pública de pré-matrícula (API que retorna dados do formulário)
|
// Página pública de pré-matrícula (API que retorna dados do formulário)
|
||||||
app.get('/api/prematricula/public/:slug?', async (req, res) => {
|
// Handler compartilhado para evitar duplicação
|
||||||
|
async function handlePublicPreMatricula(req, res, slug) {
|
||||||
try {
|
try {
|
||||||
const slug = req.params.slug || 'pre-matricula';
|
|
||||||
const { rows: cfgRows } = await pool.query(
|
const { rows: cfgRows } = await pool.query(
|
||||||
'SELECT * FROM prematricula_config WHERE (slug = $1 OR id = 1) AND status = $2 ORDER BY id ASC LIMIT 1',
|
'SELECT * FROM prematricula_config WHERE (slug = $1 OR id = 1) AND status = $2 ORDER BY id ASC LIMIT 1',
|
||||||
[slug, 'published']
|
[slug, 'published']
|
||||||
|
|
@ -3024,7 +3024,12 @@ async function startServer() {
|
||||||
escola: { nome: appData?.profile?.name || 'EduManager', logo: appData?.logo || '' }
|
escola: { nome: appData?.profile?.name || 'EduManager', logo: appData?.logo || '' }
|
||||||
});
|
});
|
||||||
} catch (e) { console.error(e); res.status(500).json({ error: e.message }); }
|
} catch (e) { console.error(e); res.status(500).json({ error: e.message }); }
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Rota sem slug (usa slug padrão)
|
||||||
|
app.get('/api/prematricula/public', (req, res) => handlePublicPreMatricula(req, res, 'pre-matricula'));
|
||||||
|
// Rota com slug explícito
|
||||||
|
app.get('/api/prematricula/public/:slug', (req, res) => handlePublicPreMatricula(req, res, req.params.slug));
|
||||||
|
|
||||||
// Rota que serve a página HTML pública do formulário de pré-matrícula
|
// Rota que serve a página HTML pública do formulário de pré-matrícula
|
||||||
app.get('/pre-matricula', async (req, res) => {
|
app.get('/pre-matricula', async (req, res) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue