Making 404 Error on glitch

Yes! its possible and easy, first you need these things:

  • Express project
  • Main file (server.js, index.js etc.)

So after making the project you will see this in your main file:

After that add line!
put this code

 app.get("/*", (request, response) => {
      response.sendFile(__dirname + "/views/404.html");
  });

So β€˜/*’ will be the para after your website, this will checks if that para exist or not
if not it will show error

Example:
image

The 404.html file

image

Heres the output: image

Hope it helps :slight_smile:

If it make sure to click :heart: button! it will rlly appriciate.

4 Likes

Wow it rlly helps me!1 thank you so much i rlly needed that…

1 Like