Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!