Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: node
apistatus-codesbfferror-handling
Return the proxy route's own status, not the upstream service's
A BFF/proxy route should respond with a status reflecting its own success/failure, not blindly forward the upstream's status to the client.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejavascript
| 1 | const upstream = await UpstreamService.get(); |
| 2 | res.status(upstream.status).json(upstream.data); // leaks upstream 404/500 as this route's status |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const upstream = await UpstreamService.get(); |
| 2 | if (!upstream.ok) return res.status(502).json({ error: 'Upstream failed' }); |
| 3 | res.status(200).json(upstream.data); |
Explanation (EN)
Objašnjenje (HR)