Caddy: discriminate backend vs frontend by Accept header
The previous fix tried to route bare /admin, /projects, /workflows
to the backend so the JS list-fetches would work, but those same
paths are also Next.js pages, so browser navigation started
returning JSON 401s.
The two surfaces share an origin and several path prefixes overlap.
The frontend's API client always sets `Accept: application/json`;
browser navigation sends `Accept: text/html,...`. Match on both path
and Accept: JSON requests go to the backend, page loads go to
Next.js.
/health and /ready stay path-only because docker healthchecks and
curl send `Accept: */*`.
Apply to a running deployment by editing
${DATA_ROOT}/caddy/Caddyfile to match this template and running
`docker compose exec caddy caddy reload --config /etc/caddy/Caddyfile`,
or just re-run install.sh.
| Repository | cpatpa/PIP |
|---|---|
| Author | Claude <noreply@anthropic.com> |
| Authored | |
| Parents | 489196a2 |
| Stats | 2 files changed , +48 , -24 |
| Part of | Caddy request dispatch (backend vs frontend on shared origin) |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-1f08f72a.md
from inside the repo you want the change in.