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

145
Visualizações
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 à 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