Repository navigation
docs: fix Fastify middleware example so Astro error pages render - #1
Closed
Donchaminade wants to merge 1 commit into
Closed
Donchaminade wants to merge 1 commit into
Donchaminade wants to merge 1 commit into
Conversation
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>
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.
Description (required)
The
@astrojs/nodeFastify middleware example calledapp.use(ssrHandler), which always passesnextinto the adapter handler. For unmatched routes, the adapter then callsnext()instead of rendering Astro error pages, sosrc/pages/404.astronever runs and the response is Fastify’s empty/default 404.This updates the English Fastify example to:
/_astro/(useful for setups such as@fastify/aws-lambda)nextfor other requests so pages, API routes, and custom error pages renderstatingdist/clientfiles, which is incomplete (top-level only), incorrect (readdirSyncfilenames), and a poor fit when the filesystem is not the source of truthA short note covers a custom
basepath and forwarding additional static prefixes (for example, files copied frompublic/).References
Tests (passed)
pnpm exec prettier --check src/content/docs/en/guides/integrations-guide/node.mdxpnpm run check(0 errors)pnpm run lint:eslintpnpm run lint:slugcheckUpstream
This PR is on the fork only. Opening
Donchaminade/docs→withastro/docswas 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