How to remove [x-nextjs-cache] #84815
-
SummaryWe do not want to expose application's tech stack via a [x-nextjs-cache] header. How can I remove this? Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi @svyas-jeavio, you can remove the x-nextjs-cache header by stripping it either in a custom middleware or through your reverse proxy. For example, in Next.js you can add a small middleware that creates a response, deletes the “x-nextjs-cache” header, and then returns it. If you’re deploying behind Nginx, you can also remove this header at the proxy level before sending the response. Currently, Next.js doesn’t provide a built-in configuration option to disable this header directly, so handling it via middleware or at the proxy layer is the recommended approach. |
Beta Was this translation helpful? Give feedback.
-
|
You can’t remove the x-nextjs-cache header through configuration — it’s automatically added by Next.js to indicate cache behavior (HIT, MISS, STALE, etc.). If you need to hide it for security or compliance reasons, you can strip it at the proxy or CDN layer (e.g., Vercel Edge Config, CloudFront, Nginx, etc.). Example for Nginx:
Example for Vercel: In short: Next.js doesn’t provide a built-in flag to disable it, but it can be safely removed at the CDN or reverse proxy level. |
Beta Was this translation helpful? Give feedback.
You can’t remove the x-nextjs-cache header through configuration — it’s automatically added by Next.js to indicate cache behavior (HIT, MISS, STALE, etc.).
If you need to hide it for security or compliance reasons, you can strip it at the proxy or CDN layer (e.g., Vercel Edge Config, CloudFront, Nginx, etc.).
Example for Nginx:
proxy_hide_header x-nextjs-cache;Example for Vercel:
In short: Next.js doesn’t provide a built-in flag to disable it, but it can be safely removed at the CDN or reverse proxy level.