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).
frontend ruleP1stack specificStack: Next.js
nextjsstatic-assetsrewritesbasepathdeployment
Serve static assets under a basepath via a Next.js rewrite, not origin guessing
For apps mounted under a basepath, add a /basepath/static/:path* -> /static/:path* rewrite and reference plain /static paths, rather than constructing absolute origin URLs that break when deployed.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const src = `${faOriginHostname}/static/img/hero.png`; // wrong origin when deployed |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // next.config: { source: `${basepath}/static/:path*`, destination: '/static/:path*' } |
| 2 | const src = '/static/img/hero.png'; |
Explanation (EN)
Objašnjenje (HR)