Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
NestJS: How to hide an endpoint in production build?

I want to add an endpoint that would simplify development/testing. At the same time, this endpoint is not needed in production. Coming from Java world, there has always been an out of the box solution (eg with profiles), but I didn't find anything like that in the NestJS documentation.

Quastion: Is there a way to implement an endpoint in NestJS that would not be available if the app is built for production use?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

A few options depending on your use-case:

  1. Do you have an auth or role based access control scheme? Auth? NestJS has some Auth middleware that might help with this, but might be too heavyweight if this is a one-off: tutorial

  2. One fast and loose way to do this would be to return 404 based on an environment variable. Set the env var differently in your dev servers than production.

if(process.env.ENV_VAR === 'production') {
  throw new HttpException('Not Found', HttpStatus.NOT_FOUND)
}

  1. A good way to do this if you're going to need a lot of internal routes consistently in Prod or out might be to set up private and public routes by essentially adding a second server your project and proxy it differently.
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda