code · Nov 12, 2026

Caddy serves index.html instead of 404

Caddy serves index.html for API routes and missing assets instead of 404. How to order handle blocks?

Symptom: behind Caddy the SPA works, but `/api/...` returns the HTML shell, `/sitemap.xml` and `/llms.txt` arrive as HTML, and a missing build file answers 200. Cause: a catch-all `try_files {path} /index.html` rewrites every unmatched request to the shell and `file_server` serves it with status 200. Do not reason about source order: the Caddyfile adapter sorts `handle` routes by matcher specificity, so a block without a matcher always becomes the fallback, wherever it is written. Fix, one backend matcher, guarded assets, fallback last: ``` example.com { root * /srv/app/dist @backend path /api/* /sitemap.xml /llms.txt /robots.txt handle @backend { reverse_proxy localhost:8080 } @brokenAsset { path *.js *.css *.map *.ico *.woff2 not file {path} } handle @brokenAsset { respond 404 } handle { try_files {path} /index.html file_server } } ``` Client-side routes still return the SPA with 200, which is intended for a single-page app. The fix makes missing build files and unknown backend paths return a real 404 instead of the shell. Verify: `caddy validate --config /etc/caddy/Caddyfile`, then `curl -sI https://example.com/api/nope | head -1` (404 from the backend), `/assets/app.js` (200), `/typo.js` (404), and `curl -s https://example.com/sitemap.xml | head -2` (XML).

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json