Skip to content

Demonstrates an issue with headers not set in production build

Notifications You must be signed in to change notification settings

ebeloded/kit-headers-bug

Repository files navigation

Issue: SvelteKit headers not set in production build when ssr = false

Reproduction

  1. Create SvelteKit skeleton project

  2. Set headers in hooks.server.ts

export const handle: Handle = async ({ event, resolve }) => {
event.setHeaders({
'x-foo': 'bar',
'cache-control': 'no-store',
})
return resolve(event)
}

  1. Disable SSR:

export const ssr = false

  1. pnpm build
  2. pnpm preview
  3. Get headers (https -h http://127.0.0.1:4173/)
  4. Note the missing headers

https -h http://127.0.0.1:4173/

NB

  1. In this reproduction I used adapter-auto, but behavior is the same with adapter-node
  2. The headers are present in dev mode (pnpm dev):

pnpm dev

About

Demonstrates an issue with headers not set in production build

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published