Repository navigation
Commit 6653744
authored
fix(docs): serve a docs 404 from the prerendered not-found route (#192)
Fixes #182
/docs/no-such-page returned a correct 404 status with an empty body: the 404
markup reached the RSC payload but never the server-rendered HTML, so crawlers
and no-JS clients got a blank page while every browser filled it in.
Root cause: notFound() raised while a request is rendered dynamically escapes
both the RSC and the SSR render. Next builds the response from
getErrorRSCPayload, which seeds the document as an empty error shell and ships
the real 404 tree only in the payload. No not-found boundary participates in
that server render at any depth — measured at the root, in the locale segment,
with the shell relocated above the boundary, and via the experimental
global-not-found convention. A boundary in the locale segment is byte-for-byte
a no-op, which is why this is a routing flag and not a new not-found.tsx.
dynamicParams = false routes an unknown docs slug to the prerendered
/_not-found route — an ordinary page render, which is why /no-such-page always
worked. It removes the dynamic render the boundary cannot survive.
Cost: a page not in the enumeration needs a rebuild to appear. Every page here
comes from local MDX that generateStaticParams already enumerates, so that is
true in practice today; the OG route sets the same flag for the same reason.
Verified on a same-base A/B: control errorshell=TRUE with 0 occurrences of the
404 copy in markup, branch errorshell=FALSE with the copy present, across the
en/zh-Hans/ja and nested variants. /no-such-page unchanged, static count 577 on
both sides, redirects intact, next dev matching.
A docs 404 still declares en rather than the requested locale; that half is #191.1 parent b078736 commit 6653744
1 file changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
271 | 305 | | |
272 | 306 | | |
273 | 307 | | |
| |||
0 commit comments