configurar acesso externo

This commit is contained in:
Luiz Silva 2024-09-13 15:54:43 -03:00
parent a667b04285
commit 3bd075c39d
2 changed files with 639 additions and 632 deletions

View file

@ -143,18 +143,21 @@ gerar.then(() => {
.send(html404.replace("{ERRO}", `Página não encontrada: ${request.url}`));
});
const jaEstaRodando = fetch(`http://127.0.0.1:${PORTA}`)
const jaEstaRodando = fetch(`http://0.0.0.0:${PORTA}`)
.then(() => true)
.catch(() => false);
jaEstaRodando.then((jaEstaRodando) => {
!jaEstaRodando &&
fastify.listen({ port: Number(PORTA) }, (err, address) => {
if (err) throw err;
console.log(
`${new Date().toISOString()} Servidor ${PREFIXO} Rodando em ${address}`,
);
});
fastify.listen(
{ port: Number(PORTA), host: "0.0.0.0" },
(err, address) => {
if (err) throw err;
console.log(
`${new Date().toISOString()} Servidor ${PREFIXO} Rodando em ${address}`,
);
},
);
jaEstaRodando && console.log(`Servidor ${PREFIXO} já está rodando`);
});