Forever Loops To Make A 404 Screen

I fixed it to use app.use.

You donā€™t need the "*" then though, so it just becomes the same. Keep it as the get it is different and valid, itā€™s worth sharing :slight_smile:

window.location will give you the current URL

You can use that to make some mess of code that changes the body to a 404 page if it doesnā€™t match a list of links.

Orā€¦ JUST USE EXPRESS

That seems kind wrong, there is probably a builtin error handler for express, and a built-in way to serve errors, so it makes no sense to go route-by-route

1 Like

Ok, Iā€™ll settle the debate. Since the user is using an HTML, CSS, and JS repl, this is no different than just using a Node.js repl and using express, the only difference is that you have to use the .js file INSIDE of the html file index.html, and for a basic html page for the home page, you can insert the following code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>replit example page</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
  Hello World
  <script src="script.js"></script>

  <script src="https://replit.com/public/js/replit-badge-v2.js" theme="dark" position="bottom-right"></script>
</html>

Do note that this is only an example of what an HTML page looks like, this example can be changed to your likings.

1 Like

That is not the only difference, almost all node things donā€™t work front-end, and although they are the same language, they are completely different.

1 Like