fix(website): prerender every template page instead of only the first 30 - #180
Open
bariscelik wants to merge 1 commit into
Open
fix(website): prerender every template page instead of only the first 30#180bariscelik wants to merge 1 commit into
bariscelik wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On dokploy.com/templates, only the first 30 template pages work. Every other template detail page returns a plain
Internal Server Error(HTTP 500).The
/templateslisting links to all 518 templates, so 488 of those links are currently dead for both visitors and search engines.The cutoff is exactly alphabetical position 30:
/templates/ackee/templates/answer/templates/argilla/templates/audiobookshelf/templates/authentikCause
generateStaticParamsinapp/templates/[id]/page.tsxcaps the prerendered set at 30:With
dynamicParams = true, the remaining 488 templates are left to on-demand rendering, and that path fails on the deployed site. Response headers confirm the split: working pages carryx-nextjs-prerender: 1andx-nextjs-cache: HIT, while the failing ones carry no prerender header at all.The on-demand render does start (an unknown slug such as
/templates/does-not-existstill returns a correct 404 throughnotFound()), but rendering real template content on-demand 500s in production. Pure SSR routes such as/templatesand/blog/<post>are unaffected, so this is specific to the non-prerendered ISR path.Fix
Prerender every template, which is what the sibling
blog/tag/[tag]route already does:These pages are SEO landing pages for a catalog that changes only when the templates repo is updated, so building all of them is the intended shape.
dynamicParamsstaystrue, so a template added upstream between deploys isstill handled.
Verification
Both branches were rebuilt clean (
rm -rf .next) and served withnext startusing the same runtime layout asDockerfile.website(prod-prunednode_modules, only.next,publicandpackage.json), with a cold ISR cache.x-nextjs-prerender+x-nextjs-cache: HITThe last row is the meaningful one. On a cold cache a page rendered on demand reports
MISSand carries no prerender header, so all 518 are being served from build output and none touch the failing path. Unknown slugs still return 404.Content was checked too, not just status codes. On 38 sampled pages (35 of them currently returning 500 in production), the rendered
docker-compose.ymlandtemplate.tomlbyte-match whattemplates.dokploy.comserves live, with the correct template name. 38 of 38, no mismatches.Build cost, measured before and after on the same machine:
next build.nextsizeBuild time is unchanged within noise. The tradeoff is roughly 125 MB more build output for the 488 extra HTML and RSC payloads.
What this does not prove
I was not able to reproduce the 500 itself locally. The on-demand path renders fine both in a plain production build and in the Docker-equivalent layout, so the trigger appears to be specific to the deployed container and I could not get at it from outside.
This PR therefore fixes the problem by moving all 518 pages onto the same path that already works in production, rather than by repairing the on-demand path. The underlying weakness remains: a template added upstream between site deploys would still hit the failing path until the next rebuild. If a maintainer can pull the stack trace for
GET /templates/audiobookshelffrom the deployed container logs, that would pin down the real cause and could be fixed separately.