Personal Catalogue: React, Express & MongoDB — Chapter 9, Exercise 2 ===================================================================== TASK Build the frontend (npm run build), wire express.static into server.js, and confirm the whole app is reachable and fully functional at http://localhost:4000/ alone, with no separate Vite dev server running, and with a real API call succeeding via a relative path. SOLUTION cd catalogue-web npm run build cd .. Output: a real catalogue-web/dist/ folder appears, containing index.html plus hashed .js and .css files. server.js addition: const path = require('path'); app.use(express.static(path.join(__dirname, '../catalogue-web/dist'))); Stop the Vite dev server entirely (Ctrl+C in its terminal, so nothing is listening on its usual port at all), then start only the backend: cd catalogue-api node server.js Visit http://localhost:4000/ in a browser. Observed: the real catalogue UI loads -- the same list, search bar, tag filter, and add-item form built across Chapters 4-7 -- served entirely by the one Express process, with no second dev server running anywhere. Opening the browser's Network tab and adding a new item confirms the POST request goes to the relative path /api/items (no protocol or host prefix visible in the request, since API_BASE_URL resolved to an empty string in this production build), and it succeeds, returning the newly created item and updating the visible list. WHY THIS WORKS AS AN ANSWER ---------------------------- It performs a real production build and wires up static serving exactly as the chapter describes, then proves the unified single-process deployment genuinely works end to end -- not just that the page loads, but that a real write request succeeds via a relative path with no separate frontend server involved at all.