MERN

⌘K
  1. Home
  2. Docs
  3. MERN
  4. Express.js
  5. routenotfound

routenotfound

const express = require('express');
const app = express();
const port = 3000;

// Your other routes go here

// Middleware for handling 404 errors (Not Found)
app.use((req, res, next) => {
  res.status(404).send("Sorry, the requested route doesn't exist.");
});

// Start the server
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});

How can we help?