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

134
Vistas
API is responding with status 200 when used with HEAD and OPTIONS method

I created an API with method GET using express which is working fine.

following is the API

app.get('/healthcheck', (_req, res) => {
  res.status(200).send({
    state: 'Healthy',
    timestamp: new Date(),
    uptime: process.uptime()
  });
});

I am also getting success response with status = 200 when method is replaced with HEAD or OPTIONS. Shown below.

curl --location --head 'http://localhost:2003/healthcheck'

Although with POST, PUT, PATCH etc methods I am getting status=404.

Since the created API is of type GET, I want to send 404 for all other methods like HEAD, OPTIONS, POST, PATCH etc

only follow request should give status=200

curl --location --request GET 'http://localhost:2003/healthcheck'

How can this be achieved?

about 4 years ago · Juan Pablo Isaza
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