Nuxt 3.4 server/api routes missing default Cache‑Control headers in dev mode
25.5K reputation · 06 May 2020, 03:56 UTC
Background
Nuxt 3.4 introduced the Nitro serverless routing feature, moving from the legacy serverMiddleware approach to defining REST endpoints in the server/api directory. While this change simplifies route creation, it also removes the automatic Cache‑Control header that serverMiddleware used to inject.
Unresolved Decision
During local development (running nuxt dev), responses from server/api routes are emitted without any caching headers, potentially allowing browsers or intermediaries to cache responses indefinitely. The official Nuxt 3 documentation does not specify how to configure these headers for dev mode, leaving developers to guess or manually set them via nitro.config.ts.
Specific Questions
1) What is the recommended method to set default Cache‑Control headers for all server/api routes in development mode?
2) Does Nitro apply any default caching policy to server/api routes when building for production, or must headers be explicitly defined in nitro.config.ts?
3) Are there known differences between Nuxt 3.3 and 3.4 regarding automatic caching header application for serverless routes?