Caddy: route SSE and binary requests to backend, not just JSON

↗ view on GitHub · Claude · 2026-05-16 · d8ae0d66

The previous matcher required Accept to contain application/json,
which made browser-driven streaming chat requests (Accept:
text/event-stream) fall through to the Next.js frontend and return
the 404 HTML page as the chat reply.

Invert the matcher: route to backend when the path matches AND the
Accept header does NOT contain text/html. Browser navigation always
sends text/html; JSON fetches, SSE streams, and binary downloads
never do. One rule covers all three.

Operators apply this on a running deployment with:

  sudo bash bin/pip-write-caddyfile.sh
Repository cpatpa/PIP
Author Claude <noreply@anthropic.com>
Authored
Parents 978ea483
Stats 2 files changed , +8 , -6
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-d8ae0d66.md from inside the repo you want the change in.

⬇ Download capture-commit-d8ae0d66.md