From 83f3d714ade8ae081479b4c1e5f2a97a1a588317 Mon Sep 17 00:00:00 2001 From: Danng Date: Sun, 20 Jul 2025 06:31:28 +0100 Subject: [PATCH 1/2] Update js tutorial for new path-to-regexp The old server.js code was broken as the wildcard was incorrect --- get-started/single-page-app/website.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/get-started/single-page-app/website.md b/get-started/single-page-app/website.md index 3066216..f701a61 100644 --- a/get-started/single-page-app/website.md +++ b/get-started/single-page-app/website.md @@ -105,10 +105,11 @@ const app = express(); app.use(express.static(join(__dirname, "public"))); // Serve the index page for all other requests -app.get("/*", (_, res) => { - res.sendFile(join(__dirname, "index.html")); +app.get(/.*/, (req, res) => { + res.sendFile(path.join(__dirname, "index.html")); }); + // Listen on port 3000 app.listen(3000, () => console.log("Application running on port 3000")); ``` From bedcdbe83912f23170d5d1f2ed37cf1833283049 Mon Sep 17 00:00:00 2001 From: Danng Date: Sun, 20 Jul 2025 06:37:57 +0100 Subject: [PATCH 2/2] Update website.md --- get-started/single-page-app/website.md | 1 + 1 file changed, 1 insertion(+) diff --git a/get-started/single-page-app/website.md b/get-started/single-page-app/website.md index f701a61..a909513 100644 --- a/get-started/single-page-app/website.md +++ b/get-started/single-page-app/website.md @@ -99,6 +99,7 @@ Now create a `server.js` file in the root folder of your project. Add the follow ```javascript const express = require("express"); const { join } = require("path"); +const path = require("path"); const app = express(); // Serve static assets from the /public folder