Skip to content

fix: infer prerendered MIME types from generated files - #17381

Merged
teemingc merged 3 commits into
mainfrom
triage/kit-17380-prerendered-mime
Oct 12, 2026
Merged

teemingc merged 3 commits into
mainfrom
triage/kit-17380-prerendered-mime

Conversation

@svelte-triage-bot

Copy link
Copy Markdown
Contributor
  • Prerendered URL paths omit or misrepresent generated file extensions, leaving HTML absent from builder.mimeTypes unless another asset supplies it.
  • Preserve the shared MIME lookup introduced by #16564, exposed by #16875, and consumed by the build-time static server in #16908, including manifest precedence and the patched icon type.
  • Scan actual prerendered output alongside client output rather than adding only page filenames: the latter misses redirect-only output and retains misleading URL extensions. No runtime MIME database or HTML fallback is needed.
  • Cover pages, redirects, dependencies, generated data and absent prerendered output; retain static HTML alias coverage while adding a no-static-assets variant and nosniff, HEAD and compression regressions.

Fixes #17380

@changeset-bot

changeset-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c74942

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit 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

@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 1c74942:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/1c7494291b67ed4d451b53a013bca2252779dbb8

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17381

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@dummdidumm

Copy link
Copy Markdown
Member

@svelte-triage-bot do we need the additional test in adapter-node or does the one in core suffice? asking because there is no actual code change in adapter-node itself

@dummdidumm

Copy link
Copy Markdown
Member

(but answered on the issue #17380 (comment) will dig into why)

(I think I would still be in favor of removing the node test to not make everything take even longer)

@theescodes

theescodes commented Oct 8, 2026 •

Copy link
Copy Markdown

Tested this on a production site that hit #17380. The site is fully prerendered, on Kit 3.0.0 and adapter-node 6.0.0, and served through a custom server that wraps handler and sets X-Content-Type-Options: nosniff.

I applied this PR's builder.js change to the installed Kit and rebuilt:

  • mime_types in build/adapter-node.js now includes ".html":"text/html". Before, it had none; .xml was only there because of a prerendered sitemap.
  • /, /about and /imprint are served as text/html;charset=utf-8. Before, they had no Content-Type.
  • Other types are unchanged: sitemap.xml is still text/xml and favicon.ico is still image/x-icon.
  • In Chromium the pages render again instead of showing their source. Client-side navigation works, and the CSP reports no violations.

Thanks in advance for the quick fix!

@teemingc
teemingc marked this pull request as ready for review October 12, 2026 05:56
@teemingc
teemingc merged commit 230d00c into sveltejs:main Oct 12, 2026
36 of 37 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
teemingc added a commit that referenced this pull request Oct 14, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @sveltejs/kit@3.1.0

### Minor Changes

- feat: support `report-sha256`/`report-sha384`/`report-sha512` CSP
hash-reporting keywords
([#17398](#17398))

- feat: emit a `sveltekit.endpoint` span for `+server` handlers when
server tracing is enabled
([#17325](#17325))

### Patch Changes

- fix: don't treat every module as server-only when the project is
inside a `server` directory
([#17376](#17376))

- fix: continue deployment recovery when service worker updates fail
([#17440](#17440))

- fix: infer prerendered MIME types from generated files
([#17381](#17381))

- fix: leave generated files alone when their contents are unchanged
([#17310](#17310))

- fix: leave focus in the parent page when an app in an unfocused iframe
starts or navigates
([#17297](#17297))

- fix: don't warn about Storybook's Vite plugins that use
`transformIndexHtml`
([#17373](#17373))
## @sveltejs/adapter-cloudflare@8.0.1

### Patch Changes

- fix: start the dev server on runtimes such as Deno that define
`caches` as a getter-only global
([#17401](#17401))

- fix: start one platform proxy for concurrent Vite servers and keep it
alive until the last one closes
([#17368](#17368))

- fix: support `Span#setStatus` and `Span#updateName` on local emulation
of Cloudflare `tracing`
([#17400](#17400))
- Updated dependencies:
  - @sveltejs/kit@3.1.0
## @sveltejs/adapter-vercel@7.0.1

### Patch Changes

- fix: keep the detected Bun minor in the resolved runtime
([#17331](#17331))
- Updated dependencies:
  - @sveltejs/kit@3.1.0
## @sveltejs/package@3.0.1

### Patch Changes

- fix: emit component types for the installed Svelte version, rather
than the oldest one the `svelte` dependency range allows
([#17330](#17330))

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
dadezzz pushed a commit to dadezzz/events-cash-register that referenced this pull request Oct 18, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@sveltejs/kit](https://svelte.dev) ([source](https://github.com/sveltejs/kit/tree/HEAD/packages/kit)) | [`3.0.1` → `3.1.0`](https://renovatebot.com/diffs/npm/@sveltejs%2fkit/3.0.1/3.1.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@sveltejs%2fkit/3.1.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@sveltejs%2fkit/3.0.1/3.1.0?slim=true) |

---

### Release Notes

<details>
<summary>sveltejs/kit (@&#8203;sveltejs/kit)</summary>

### [`v3.1.0`](https://github.com/sveltejs/kit/blob/HEAD/packages/kit/CHANGELOG.md#310)

[Compare Source](https://github.com/sveltejs/kit/compare/@sveltejs/kit@3.0.1...@sveltejs/kit@3.1.0)

##### Minor Changes

- feat: support `report-sha256`/`report-sha384`/`report-sha512` CSP hash-reporting keywords ([#&#8203;17398](sveltejs/kit#17398))

- feat: emit a `sveltekit.endpoint` span for `+server` handlers when server tracing is enabled ([#&#8203;17325](sveltejs/kit#17325))

##### Patch Changes

- fix: don't treat every module as server-only when the project is inside a `server` directory ([#&#8203;17376](sveltejs/kit#17376))

- fix: continue deployment recovery when service worker updates fail ([#&#8203;17440](sveltejs/kit#17440))

- fix: infer prerendered MIME types from generated files ([#&#8203;17381](sveltejs/kit#17381))

- fix: leave generated files alone when their contents are unchanged ([#&#8203;17310](sveltejs/kit#17310))

- fix: leave focus in the parent page when an app in an unfocused iframe starts or navigates ([#&#8203;17297](sveltejs/kit#17297))

- fix: don't warn about Storybook's Vite plugins that use `transformIndexHtml` ([#&#8203;17373](sveltejs/kit#17373))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjUuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE2NS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
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.

adapter-node: prerendered pages are served without a Content-Type

3 participants