configurar acesso externo
This commit is contained in:
parent
a667b04285
commit
3bd075c39d
2 changed files with 639 additions and 632 deletions
|
|
@ -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`);
|
||||
});
|
||||
|
|
|
|||
1254
src/index.ts
1254
src/index.ts
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue