Fix: Ensure 404 page always shows route suggestions #4672
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.
Fixes FER-[ticket number needed]
Changes Made
This PR fixes the 404 page to always show route suggestions. Previously, users would see "Finding similar pages..." but no suggestions would appear.
Root cause: The
getRouteSuggestionsserver action was failing with a runtime error because the not-found routes were running on Edge runtime but importing Node-only modules (@fern-api/docs-loader,getDocsHostApp).Solution:
export const runtime = "nodejs"to both not-found.tsx files to force Node runtimeWhat was the motivation & context behind this PR?
Reported by @dannysheridan in Slack thread. When users hit 404 pages like:
https://buildwithfern.com/learn/sdks/overview/custom-codhttps://buildwithfern.com/learn/sdks/autopilotThe page showed "Finding similar pages..." but never displayed suggestions. Browser console showed server component render errors.
How has this PR been tested?
Review Checklist
Critical items to verify:
/learn/sdksfrom/learn/sdks/overview/custom-cod) lead to valid pages, not additional 404sQuestions for reviewers:
runtime = "nodejs"the right solution, or should we move this to an API route instead?Link to Devin run | Requested by @dannysheridan