Repository navigation
fix(pages): answer 404 for a missing post or changelog entry - #50
Open
MarketDataApp wants to merge 1 commit into
Open
MarketDataApp wants to merge 1 commit into
MarketDataApp wants to merge 1 commit into
Conversation
The post page read only `data` from useFetch('/api/posts/<slug>'), so a
missing post rendered an empty page with HTTP 200. The changelog entry page
showed its not-found message, also with 200. Both APIs already answer 404.
The post page has no not-found state, so it now throws the same fatal 404 the
help article page throws when the help center is off. The changelog page keeps
its message and sets the status during SSR, as the help article page does.
Closes linkcraftstudio#49
Signed-off-by: MarketDataApp <112879596+MarketDataApp@users.noreply.github.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.
What this PR does
A missing post (
/p/<slug>) or changelog entry (/changelog/<slug>) now answers HTTP 404 instead of 200.app/pages/p/[slug].vue: when/api/posts/<slug>answers 404, throwcreateError({ statusCode: 404, statusMessage: 'Not Found', fatal: true }). The post page has no not-found state of its own, so this is the same fatal 404 that the help article page already throws when the help center is off.app/pages/changelog/[slug].vue: keep the "This changelog entry was not found" message, and set the status to 404 during SSR withsetResponseStatus, exactly asapp/pages/help/[slug].vuealready does.Why
Closes #49
Both APIs already answer 404, but the pages answered 200 (a "soft 404"): search engines index the empty or not-found pages, a deleted post stays in search results, and link checkers cannot see the broken link.
We (Market Data) run a FeedLog fork in production at https://roadmap.marketdata.app and found it in an SEO audit. On our staging deployment with this commit:
/p/this-post-does-not-exist/changelog/this-entry-does-not-exist/,/roadmap,/changelogOpening a post from the board list (the overlay) still works, with no page errors.
How to review
Two small hunks. The post page checks
error.value?.statusCode === 404only, so other API errors behave as before. The changelog page mirrors the help article page's existingif (import.meta.server && error.value) setResponseStatus(useRequestEvent()!, 404). On client-side navigation the changelog page shows its message as before (setResponseStatusis a no-op in the browser).Checklist
git commit -s)pnpm build)pnpm generate:migration) and committed (no schema change)README.md/.env.example/docs/deploy/*updated (no change)