Romaji to Kana Converter: Angular & Express — Chapter 8, Exercise 2 ===================================================================== TASK Configure the nginx location /romaji/ block against a real running instance of the app (a second local nginx config is fine for testing), and confirm both a page load and a real /api/convert request succeed through the proxy, with server.js completely unchanged from Chapter 7. SOLUTION // /etc/nginx/sites-available/romaji-test (a local test vhost, e.g. // listening on port 8080 so it doesn't collide with anything else) server { listen 8080; server_name localhost; location /romaji/ { proxy_pass http://localhost:4000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } $ sudo ln -s /etc/nginx/sites-available/romaji-test /etc/nginx/sites-enabled/ $ sudo nginx -t && sudo systemctl reload nginx With the real Express server from Chapter 7 already running on port 4000 (server.js completely untouched -- no edits made to it for this exercise at all): $ curl -s http://localhost:8080/romaji/ | grep -o '[^<]*' <title>Romaji to Kana Converter $ curl -s -X POST http://localhost:8080/romaji/api/convert \ -H "Content-Type: application/json" -d '{"romaji":"sushi"}' {"hiragana":"すし","katakana":"スシ"} Both requests succeed through the proxy. Checking Express's own console output during the second request confirms it logged the request as arriving at exactly /api/convert -- the /romaji prefix was genuinely stripped by nginx before Express ever saw the request, not handled by any code inside server.js. WHY THIS WORKS AS AN ANSWER ---------------------------- It confirms the trailing-slash prefix-stripping behavior this chapter describes actually happens, for both a static page request and a real API POST request, using an entirely real nginx config and a real running Express process with zero changes made to server.js. Express routes /api/convert exactly as it has since Chapter 5, with no awareness that a reverse proxy or a /romaji prefix exist at all -- the path-mounting is handled entirely at the nginx layer.