Intermediate
Write the SPA fallback rule
Finish host(path), a model of a static host serving dist/. It returns a string:
- a file that exists in dist → "200 " + file (and / means /index.html);
- a missing path under /assets/ → "404" (a missing JS file must never get HTML);
- any other path → "200 /index.html" (the SPA fallback, so the router can handle it).
The input #path, the button #go and the result #result are already wired up.
What Check tests
- A real asset is served as itself
/serves/index.html- A deep link like
/products/42falls back toindex.html - A missing asset is an honest 404
- Other real files still work
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.