Exercise 2: Why the Catch-All Route Is Still Needed Alongside React Router — Possible Solution ==================================================================== WHAT REACT ROUTER HANDLES, AND WHAT IT DOESN'T ------------------------------ React Router manages navigation entirely inside the already-loaded page, in the browser - clicking a link to /history updates the URL and swaps which component renders, all without a new request ever leaving the browser. But React Router only exists once the page's own JavaScript has actually loaded and run - it has no control at all over what happens before that point. WHAT HAPPENS ON A DIRECT REQUEST OR A REFRESH ------------------------------ If a user directly navigates to /history (types the URL, refreshes the page, or opens it from a bookmark), the browser sends a real HTTP request straight to the Express server for the path /history. Express has no actual file or route matching that path - there's no server-side concept of "/history" at all, since it only ever existed as a client-side React Router route. Without the catch-all, Express would correctly return a 404, since nothing on the server matches that path. WHY THE CATCH-ALL FIXES THIS ------------------------------ By returning index.html for any unmatched path, the catch-all ensures the browser always receives the same React application shell no matter which URL was requested directly. Once that HTML loads and its JavaScript runs, React Router reads the current URL (/history) and renders the correct view - the catch-all's job is only to get the app's own JavaScript loaded in the first place; React Router takes over from there. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly distinguishes between what React Router controls (in-browser navigation after the page has loaded) and what it has no control over (the server's own response to a direct request for a client-side-only route), and correctly explains that the catch-all's job is specifically to bridge that gap by always serving the same app shell.