Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Vary header is being overwritten by Next causing CDN issues | GoodFirstPicks

Vary header is being overwritten by Next causing CDN issues

vercel/next.js 0 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

The issue involves modifying header behavior in Next.js, which requires understanding of middleware and headers.

AI Summary

The issue describes a problem where the Vary header is being overwritten by Next.js, causing CDN cache invalidation issues. The solution likely involves modifying how headers are handled in middleware or the Next.js core. The main blocker is understanding the internal header manipulation logic in Next.js.

Issue Description

Link to the code that reproduces this issue

https://github.com/hbystrom91/next-vary-header-content-encoding-bug

To Reproduce

  1. Start the application using the README.md instructions
  2. Navigate to the root page and open the networks tab
  3. Inspect the Vary header

Current vs. Expected behavior

Current behavior

Image

Looking at the image, you can see that the arbitrary header is added, but the X-Foo entry isn't appended to the Vary header.

Expected behavior

Not being able to do this causes our CDN not being able to invalidate cache based on the Vary tag. Since it also compresses all responses, this is needed. By adding compress: true in the next.config.js the appropriate Accept-Encoding entry is added to the Vary header, but we need this to happen at the CDN level. Right now we cannot compress our app router pages, because Next.JS simply doesn't give us the flexibility. There's many other use cases for when flexibility is needed in this regard.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.20.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: 10.18.3
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Headers, Middleware

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

No response

GitHub Labels

Middlewarelinear: nextHeaders

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • header manipulation
  • CDN integration
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno