From bc452cb48aad05213c2500933e0fe08f70607a6c Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:24:54 -0500 Subject: [PATCH] fix(nginx): return JSON errors for unmatched api/feed/backup paths 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 //api/... routes are matched earlier and are unaffected. --- root/etc/nginx/template.conf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/root/etc/nginx/template.conf b/root/etc/nginx/template.conf index 8b9b788..5786671 100644 --- a/root/etc/nginx/template.conf +++ b/root/etc/nginx/template.conf @@ -153,6 +153,23 @@ http { fastcgi_index index.php; } + location = /api { + default_type application/json; + return 404 '{"error":"not found"}'; + } + location = /feed { + default_type application/json; + return 404 '{"error":"not found"}'; + } + location = /backup { + default_type application/json; + return 404 '{"error":"not found"}'; + } + location ~ ^.*\/(?:api|feed|backup)(?:$|\/) { + default_type application/json; + return 404 '{"error":"not found"}'; + } + # Health check location /health { return 200 'healthy';