Skip to content

docs: fix Fastify middleware example so Astro error pages render - #1

Closed
Donchaminade wants to merge 1 commit into
mainfrom
cursor/fastify-middleware-error-pages-0e43
Closed

Donchaminade wants to merge 1 commit into
mainfrom
cursor/fastify-middleware-error-pages-0e43

Conversation

@Donchaminade

@Donchaminade Donchaminade commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Description (required)

The @astrojs/node Fastify middleware example called app.use(ssrHandler), which always passes next into the adapter handler. For unmatched routes, the adapter then calls next() instead of rendering Astro error pages, so src/pages/404.astro never runs and the response is Fastify’s empty/default 404.

This updates the English Fastify example to:

  • Let Fastify serve hashed client assets under /_astro/ (useful for setups such as @fastify/aws-lambda)
  • Call the Astro handler without next for other requests so pages, API routes, and custom error pages render
  • Avoid listing or stating dist/client files, which is incomplete (top-level only), incorrect (readdirSync filenames), and a poor fit when the filesystem is not the source of truth

A short note covers a custom base path and forwarding additional static prefixes (for example, files copied from public/).

References

Tests (passed)

  • pnpm exec prettier --check src/content/docs/en/guides/integrations-guide/node.mdx
  • pnpm run check (0 errors)
  • pnpm run lint:eslint
  • pnpm run lint:slugcheck

Upstream

This PR is on the fork only. Opening Donchaminade/docs → withastro/docs was blocked: GraphQL: Resource not accessible by integration (createPullRequest).

Compare URL for the upstream PR: withastro/docs@main...Donchaminade:docs:cursor/fastify-middleware-error-pages-0e43

Open in Web Open in Cursor 

Calling the Node adapter handler as Fastify/middie middleware passes
next, so unmatched routes skip 404.astro. Forward /_astro/ assets to
Fastify and invoke the handler without next for application routes.

Co-authored-by: chaminade Dondah Adjolou  <chaminade.adjolou@lomebs.com>
@cursor
cursor Bot deleted the cursor/fastify-middleware-error-pages-0e43 branch September 16, 2026 16:06
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 detail for node adapter middleware examples

2 participants