Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

283
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda