Romaji to Kana Converter: React & Next.js — Chapter 8, Exercise 1 ===================================================================== TASK Chapter 5 also built a client-side box that calls convert() directly, with no fetch() call at all. Explain, using this chapter's own real findings, why that box needs no basePath fix whatsoever, while the server-comparison box's own fetch call does. SOLUTION The real basePath gotcha this chapter demonstrated is specifically about URLs -- a string like "/api/convert" that has to correctly resolve to wherever the app is actually mounted, whether that's the real web root or a real subpath like /romaji/. The problem only exists at all because a fetch() call has to know, and get right, an actual network address to send a request to. The client-side box has no such string anywhere in it. Its own onChange handler calls convert(input) directly -- a plain, synchronous JavaScript function call inside the same already-loaded React component. There's no URL involved at any point: no request is constructed, no path is resolved, nothing is sent over the network at all. convert() doesn't live "at" a path the way /api/convert does; it lives wherever the component's own already-loaded JavaScript happens to be, which is already correct by construction the instant the page itself has loaded successfully. Put differently, basePath's own real job -- and the real reason a raw fetch() call can get it wrong -- is rewriting where a browser looks for something. A function call was never "looked for" anywhere; it's just called, on an object reference the component already holds. That category of gotcha structurally cannot apply to code that never builds a URL string in the first place, which is exactly why the client-side box needed zero changes anywhere in this chapter, while the server-comparison box's own one hardcoded "/api/convert" string was the one real line that had to change. WHY THIS WORKS AS AN ANSWER ---------------------------- It correctly identifies that the basePath gotcha is fundamentally a URL-resolution problem, and that convert() called directly involves no URL at any point -- a plain function call has nothing for basePath to get wrong, which is why only the fetch-based box needed a real fix.