Skip to content

Fix Node.js adapter static file serving with build format 'file' and 'preserve'#16922

Merged
matthewp merged 1 commit into
mainfrom
flue/fix-16570
May 30, 2026
Merged

Fix Node.js adapter static file serving with build format 'file' and 'preserve'#16922
matthewp merged 1 commit into
mainfrom
flue/fix-16570

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • Fixes clean URLs (e.g., /about) not resolving to static HTML files when using build.format: 'file' or 'preserve' with the Node.js adapter
  • Adds extensions: ['html'] option to the send() call in serve-static.ts when buildFormat is 'file' or 'preserve', enabling the send library to automatically append .html when resolving extensionless paths
  • Resolves issue where only the index page worked while all other prerendered pages returned 404 despite the .html files existing on disk

Testing

  • Added packages/integrations/node/test/build-format-file.test.ts with 6 test cases covering both 'file' and 'preserve' formats
  • Tests verify clean URL resolution, explicit .html extension handling, and correct file output structure
  • Verified existing tests continue to pass with no regressions

Docs

  • No docs update needed — this fixes existing documented behavior that was broken

Closes #16570

@astrobot-houston astrobot-houston added the fix verified Reporter confirmed the triage bot fix works label May 30, 2026
@changeset-bot

changeset-bot Bot commented May 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 18deae9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@astrojs/node Patch
@e2e/actions-blog Patch
@e2e/actions-react-19 Patch
@e2e/csp-server-islands Patch
@e2e/i18n Patch
@e2e/server-islands-key Patch
@e2e/server-islands Patch
@e2e/view-transitions Patch
@test/cache-route Patch
@test/client-address-node Patch
@test/live-loaders Patch
@test/request-signal Patch
@test/ssr-api-route Patch
@test/static-build-ssr Patch
@test/nodejs-api-route Patch
@test/nodejs-badurls Patch
@test/nodejs-encoded Patch
@test/nodejs-errors Patch
@test/nodejs-headers Patch
@test/nodejs-image Patch
@test/locals Patch
@test/node-middleware Patch
@test/nodejs-prerender-404-500 Patch
@test/nodejs-prerender Patch
@test/nodejs-prerendered-error-page-fetch Patch
@test/nodejs-preview-headers Patch
@test/redirects Patch
@test/node-sessions Patch
@test/ssr-assets-middleware Patch
@test/node-static-headers Patch
@test/node-trailingslash Patch
@test/url Patch
@test/well-known-locations Patch
@test/sitemap-ssr Patch
astro-benchmark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label May 30, 2026
@matthewp matthewp merged commit 7dce185 into main May 30, 2026
26 checks passed
@matthewp matthewp deleted the flue/fix-16570 branch May 30, 2026 20:29
@astrobot-houston astrobot-houston mentioned this pull request May 30, 2026
ematipico added a commit that referenced this pull request Jun 2, 2026
* chore(deps): resolve peer dependency issues (#16894)

* chore(deps): update eslint to v10 (#16896)

* test(vercel): add per-test timeout and raise suite timeout (#16898)

* chore: eliminate duplicate pnpm configurations (#16906)

* Fix i18n redirectToDefaultLocale not working with prefixDefaultLocale (#16887)

* fix(i18n): preserve ROUTE_TYPE_HEADER for i18n post-processing (#16800)

* chore: move fix somewhere else

* chore: update changeset

---------

Co-authored-by: ematipico <estoppa@cloudflare.com>

* feat(fonts): better bold fallbacks (#16908)

* [ci] format

* fix(docs): replace last occurrences of `withastro/adapters` (#16693)

* fix: astro() marks all pipeline features as used (#16899)

* fix: astro() marks all pipeline features as used

AstroHandler is the batteries-included handler that wires up every
pipeline feature internally. Mark all PipelineFeatures bits at the
top of handle() so the one-shot warnMissingFeatures check in BaseApp
never fires a false positive when the first request short-circuits
(e.g. a redirect route skips middleware).

* add changeset

* move allFeatures mask to base-pipeline.ts per review

* docs: fix typos in astro:i18n middleware JSDoc (#16574)

* docs: fix outdated Partytown link (#16865)

* chore(deps): update devalue (#16900)

* Pre-bundle astro/fetch and astro/hono in Cloudflare optimizeDeps (#16914)

## Goal
Eliminate the 'new dependencies optimized: astro/fetch' warning during dev
in the Cloudflare adapter. The advanced routing feature (d69f858, #16366)
introduced astro/fetch and astro/hono exports, and the Cloudflare handler
entry points (01aa164, #16729) import from them — but neither commit
added these to the optimizeDeps.include list. Vite discovers them at runtime
and triggers a late re-optimization.

## Decisions
- Added both astro/fetch and astro/hono: the Cloudflare adapter imports from
  both (hono.ts imports FetchState from astro/fetch, and astro/hono is used
  similarly). Pre-bundling both prevents the same issue for either entry point.

## Changes
- packages/integrations/cloudflare/src/index.ts: added astro/fetch and
  astro/hono to the server environment optimizeDeps.include array, alongside
  the existing astro/app and astro/app/fetch/default-handler entries.

* fix(node): serve prerendered pages with build.format 'file' and 'preserve' by passing extensions option to send (#16922)

* [ci] format

* chore(deps): update `pnpm/action-setup` to v6 (#16904)

* chore(deps): update pnpm to v11.5.0 (#16903)

* Fix 404 route resolution for experimental.advancedRouting with astro/hono handlers (#16911)

Co-authored-by: Emanuele Stoppa <estoppa@cloudflare.com>
Co-authored-by: Matthew Phillips <matthew@matthewphillips.info>

* dedupe

---------

Co-authored-by: ocavue <ocavue@users.noreply.github.com>
Co-authored-by: btea <2356281422@qq.com>
Co-authored-by: Houston (Bot) <108291165+astrobot-houston@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Florian Lefebvre <florian-lefebvre@users.noreply.github.com>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Co-authored-by: Matthew Phillips <matthewphillips@cloudflare.com>
Co-authored-by: dfedoryshchev <64079946+dfedoryshchev@users.noreply.github.com>
Co-authored-by: Andreas Deininger <andreas@deininger.net>
Co-authored-by: Houston (Bot) <matthewp@users.noreply.github.com>
Co-authored-by: Matthew Phillips <matthew@matthewphillips.info>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected server behaviour using file output

2 participants