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 ruleP2stack specificStack: node
nextjsapi-routesdata-fetchingcorrectness
Do not put page data-fetching functions in API routes
Server data-fetching functions only run for rendered pages; they have no effect when placed in an API route handler.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codets
| 1 | // pages/api/create-thread.ts |
| 2 | export const getServerSideProps = async () => ({ props: {} }); // never runs here |
| 3 | export default handler; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // pages/api/create-thread.ts |
| 2 | export default async function handler(req, res) { |
| 3 | // API route logic only |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)