* fix(relay): wrap non-JSON upstream errors in JSON envelope
When upstream services (Cloudflare, nginx) return HTML error pages
(502/503), the relay handler passed them through with the original
content-type. Clients expecting JSON would fail to parse the response,
causing silent panel failures in the desktop app.
Extracts a buildRelayResponse() helper that detects non-JSON error
responses and wraps them in a { error, status } JSON envelope. Success
responses and JSON error responses pass through unchanged.
Applies the same fix to the telegram-feed handler which had an
identical passthrough pattern.
Ref #976
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(relay): address review feedback on buildRelayResponse
- Export buildRelayResponse so telegram-feed.js can use it directly,
eliminating the duplicate inline implementation
- Fix +json content-type detection: use /json and +json substring checks
so application/vnd.api+json and application/problem+json responses are
treated as JSON and passed through unchanged instead of being wrapped
- Add console.warn with body preview when wrapping, to aid production debugging
- Include HTTP status code in the error message for actionable diagnostics
- Update tests: vnd.api+json errors now pass through; error assertions use
startsWith so they remain valid as the message evolves
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Elie Habib <elie.habib@gmail.com>