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 / Next.js
configurationenvironmentsportabilityhttp
Don't hardcode host and port; resolve them in a deployment-stable way
A handler that fetches http://localhost:3000 only works locally. Determine host/port from the framework/runtime so it works in every environment.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | await fetch('http://localhost:3000/', { method: 'HEAD' }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const base = process.env.APP_BASE_URL ?? new URL(request.url).origin; |
| 2 | await fetch(`${base}/`, { method: 'HEAD' }); |
Explanation (EN)
Objašnjenje (HR)