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

111
Vistas
Express ignores response.send() call

I have a simple server. Code is explained below:

const express = require("express");
 
const app = express();
 
app.set("view engine", "hbs");
 
app.get("/about-me", function(_, response) {
    response.render("about_me.hbs");
});
app.get("/", function (_, response) {
    response.render("index.hbs");
});
app.all(/.*/, function (_, response) { // 404 page
    response.sendStatus(404); // set status code to 404
    response.send("<h1>404 Not Found</h1>"); // send a body
}
app.listen(3000);

But when I opened http://localhost:3000/not-exist , there was "Not Foun<" text. Why it's happening?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't send two responses to a single request.

Use sendStatus or send.

If you want to control the status code when you use send, use status.

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