-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prerendered +server routes don't use the specified HTTP response headers #9408
Comments
This is a general prerender limitation. Prerendering means the result is on disk as a static asset, which means whatever serves those assets is in charge of defining those headers - there's no SvelteKit-aware runtime involved that could add these. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
there might be some trickery around CSP nonces to figure out if we did this: #9235 though this is a feature that could never be supported by for |
Describe the bug
Prerendering a
+server.ts
file causes its HTTP response headers to be ignored.E.g., I want to prerender an atom.xml file for a blog site. I'd like to override the
Cache-Control
andContent-Type
headers. When I addexport const prerender = true
and runpnpm preview
, this page renders withcontent-type: text/html
and nocache-control
header at all:Workaround is to only prerender HTML pages since their content type is
text/html
, and only those that don't need header overrides such asCache-Control
.Reproduction
https://github.com/BMorearty/sveltekit-prerender-headers
Clone this repo and build it for production (bug does not reproduce in dev mode):
$ pnpm install && pnpm build && pnpm preview
Then in your browser, open the Network debug panel.
Then go to http://localhost:4173/atom.xml. Note in the Network panel that the
Content-Type
is
text/html
when i should beapplication/atom+xml
, and there is noCache-Control
header. Both headers are specified in
/src/routes/atom.xml/+server.ts
but are being ignored.Also note that atom.xml renders as an HTML page, not as XML. That's due to the incorrect
Content-Type
.Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: