fix(nextjs): actionable diagnostic when the RSC preview page is not mounted - #446
Open
guitavano wants to merge 1 commit into
Open
fix(nextjs): actionable diagnostic when the RSC preview page is not mounted#446guitavano wants to merge 1 commit into
guitavano wants to merge 1 commit into
Conversation
…ounted
A GET for /deco/preview/* reaches the catch-all route handler ONLY when
app/deco/preview/[[...path]]/page.tsx is absent — with the page present,
Next's static `preview` segment out-specifies the optional [[...deco]]
catch-all and the handler never sees the request (verified against a real
next build && next start, for both real-slash and %2F-encoded keys).
Previously a missing page degraded to a cryptic
`{"error":"Unknown deco route: /deco/preview/..."}` 404 — this is exactly
how several migrated Next sites silently lost section previews. Return a
501 that names the missing file and how to create it instead. No behavior
change for correctly-configured sites.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Contexto
Vários sites Next migrados perderam silenciosamente o preview de seção, retornando:
{"error":"Unknown deco route: /deco/preview/website%2Fpages%2FPage.tsx"}A causa nesses sites é o site não montar
app/deco/preview/[[...path]]/page.tsx. O@decocms/nextjsfaz 307 de todo preview GET pra/deco/preview/*; sem a página RSC, o redirect cai no catch-all/deco/[[...deco]], cujoresolveAction()não reconhecepreview/*→ o 404 críptico acima. (Fix do site é adicionar a página; este PR é só de DX no framework.)Mudança
Quando um GET
/deco/preview/*chega no route handler — o que só acontece quando a página RSC não está montada (com ela presente, o segmento estáticopreviewtem prioridade sobre o catch-all opcional e o handler nunca é chamado) — retorna um 501 acionável nomeando o arquivo que falta e como criá-lo, em vez doUnknown deco route.Explicitamente não cai pra
handleRenderaqui: este handler roda no grafo react-server, onderenderToStringnão consegue invocar os client-reference proxies de componentes"use client"— que é justamente o motivo da página RSC dedicada existir.Por que é seguro
Zero mudança de comportamento pra sites configurados certo: eles nunca roteiam
/deco/preview/*pra este handler.Verificação
next build && next startlimpo: com a página montada,/deco/preview/*(com%2Fe com barras reais) cai na página (200); sem ela, cai no handler./deco/previewsplural continua 307). Suíte completa: 76 passando, typecheck limpo.🤖 Generated with Claude Code
Summary by cubic
Add an actionable 501 diagnostic when
/deco/preview/*hits the catch-all, guiding users to mountapp/deco/preview/[[...path]]/page.tsx. This replaces the cryptic 404 and helps restore section previews for Next.js sites using@decocms/nextjs./deco/previews/*still 307s.Written for commit 821327b. Summary will update on new commits.