Skip to content

fix(pages): answer 404 for a missing post or changelog entry - #50

Open
MarketDataApp wants to merge 1 commit into
linkcraftstudio:mainfrom
MarketData-App:fix/404-missing-pages
Open

MarketDataApp wants to merge 1 commit into
linkcraftstudio:mainfrom
MarketData-App:fix/404-missing-pages

Conversation

@MarketDataApp

Copy link
Copy Markdown

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, throw createError({ 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 with setResponseStatus, exactly as app/pages/help/[slug].vue already 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:

URL before after
/p/this-post-does-not-exist 200 (empty page) 404 (the app's error page)
/changelog/this-entry-does-not-exist 200 ("not found" message) 404 (same message)
an existing post, an existing changelog entry, /, /roadmap, /changelog 200 200

Opening 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 === 404 only, so other API errors behave as before. The changelog page mirrors the help article page's existing if (import.meta.server && error.value) setResponseStatus(useRequestEvent()!, 404). On client-side navigation the changelog page shows its message as before (setResponseStatus is a no-op in the browser).

Checklist

  • Commits are signed off (git commit -s)
  • Tests pass locally (pnpm build)
  • If schema changed, migration was generated (pnpm generate:migration) and committed (no schema change)
  • If public API or env vars changed, README.md / .env.example / docs/deploy/* updated (no change)
  • No secrets, internal URLs, or team member names in the diff

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing post or changelog entry page answers HTTP 200 instead of 404 (soft 404)

1 participant