Skip to content

fix(nginx): return JSON errors for unmatched api/feed/backup paths - #110

Merged
austinwbest merged 2 commits into
Notifiarr:developfrom
bakerboy448:claude/api-json-errors
Oct 20, 2026
Merged

austinwbest merged 2 commits into
Notifiarr:developfrom
bakerboy448:claude/api-json-errors

Conversation

@bakerboy448

@bakerboy448 bakerboy448 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem: a bare or malformed /api, /feed, or /backup path (no consumer prefix / no endpoint) falls through try_files $uri $uri/ and nginx returns an HTML 301 trailing-slash redirect (or default HTML 404). JSON API clients then fail with invalid character '<' instead of getting a parseable error. Hit in practice by arr automation repointed at starrproxy.

Fix: add location blocks that return 404 {"error":"Starr Proxy: Invalid starr route"} (same format as the app's own errors) with application/json for those unmatched api|feed|backup paths. Valid /<consumer>/api/... (and feed/backup) routes are matched by the earlier regex locations and are unaffected; /health, PHP, and static handling are unchanged.

nginx-only change; built and tested locally (see Testing).

Testing

Built the image from this branch and ran it against an empty config.

Request Status Body
GET /api, /feed, /backup, /x/api, /x/feed, /x/backup 404 application/json {"error":"Starr Proxy: Invalid starr route"}
GET /x/api/foo, /api/, /api/v3/system/status (no key) 401 application/json Starr Proxy: no apikey provided (from PHP)
same with a bogus key (header and ?apikey=) 401 application/json Starr Proxy: provided apikey is not valid or has no access
GET /health 200 healthy
GET / 200 text/html UI

bakerboy448 and others added 2 commits September 2, 2026 11:24
A bare or malformed /api, /feed, or /backup path fell through to the try_files
directory handler and got an HTML 301/404, which breaks JSON API clients
(they fail parsing with 'invalid character <'). Add location blocks that
return a 404 JSON body for those unmatched paths so clients always get JSON.
Valid /<consumer>/api/... routes are matched earlier and are unaffected.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@austinwbest
austinwbest merged commit de257d3 into Notifiarr:develop Oct 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants