Skip to content
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

ImageResponse not handling (merging) headers option correctly #67641

Closed
Luluno01 opened this issue Jul 10, 2024 · 2 comments · Fixed by #67642
Closed

ImageResponse not handling (merging) headers option correctly #67641

Luluno01 opened this issue Jul 10, 2024 · 2 comments · Fixed by #67642
Labels
bug Issue was opened via the bug report template.

Comments

@Luluno01
Copy link
Contributor

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/jovial-tree-fwk39m?file=/app/page.tsx:4,62&layout=%7B%22sidebarPanel%22%3A%22EXPLORER%22%2C%22rootPanelGroup%22%3A%7B%22direction%22%3A%22horizontal%22%2C%22contentType%22%3A%22UNKNOWN%22%2C%22type%22%3A%22PANEL_GROUP%22%2C%22id%22%3A%22ROOT_LAYOUT%22%2C%22panels%22%3A%5B%7B%22type%22%3A%22PANEL_GROUP%22%2C%22contentType%22%3A%22UNKNOWN%22%2C%22direction%22%3A%22vertical%22%2C%22id%22%3A%22clyg9bptg00063j6kfzrtt3fc%22%2C%22sizes%22%3A%5B70%2C30%5D%2C%22panels%22%3A%5B%7B%22type%22%3A%22PANEL_GROUP%22%2C%22contentType%22%3A%22EDITOR%22%2C%22direction%22%3A%22horizontal%22%2C%22id%22%3A%22EDITOR%22%2C%22panels%22%3A%5B%7B%22type%22%3A%22PANEL%22%2C%22contentType%22%3A%22EDITOR%22%2C%22id%22%3A%22clyg9bptg00023j6k3w4rphuo%22%7D%5D%7D%2C%7B%22type%22%3A%22PANEL_GROUP%22%2C%22contentType%22%3A%22SHELLS%22%2C%22direction%22%3A%22horizontal%22%2C%22id%22%3A%22SHELLS%22%2C%22panels%22%3A%5B%7B%22type%22%3A%22PANEL%22%2C%22contentType%22%3A%22SHELLS%22%2C%22id%22%3A%22clyg9bptg00043j6kmh0go18l%22%7D%5D%2C%22sizes%22%3A%5B100%5D%7D%5D%7D%2C%7B%22type%22%3A%22PANEL_GROUP%22%2C%22contentType%22%3A%22DEVTOOLS%22%2C%22direction%22%3A%22vertical%22%2C%22id%22%3A%22DEVTOOLS%22%2C%22panels%22%3A%5B%7B%22type%22%3A%22PANEL%22%2C%22contentType%22%3A%22DEVTOOLS%22%2C%22id%22%3A%22clyg9bptg00053j6kuo9qzs1s%22%7D%5D%2C%22sizes%22%3A%5B100%5D%7D%5D%2C%22sizes%22%3A%5B50%2C50%5D%7D%2C%22tabbedPanels%22%3A%7B%22clyg9bptg00023j6k3w4rphuo%22%3A%7B%22tabs%22%3A%5B%7B%22id%22%3A%22clyg9bptg00013j6kpjw6zalf%22%2C%22mode%22%3A%22permanent%22%2C%22type%22%3A%22FILE%22%2C%22filepath%22%3A%22%2FREADME.md%22%2C%22state%22%3A%22IDLE%22%7D%2C%7B%22id%22%3A%22clyga1kel00023j6jbbv43sut%22%2C%22mode%22%3A%22permanent%22%2C%22type%22%3A%22FILE%22%2C%22initialSelections%22%3A%5B%7B%22startLineNumber%22%3A4%2C%22startColumn%22%3A62%2C%22endLineNumber%22%3A4%2C%22endColumn%22%3A62%7D%5D%2C%22filepath%22%3A%22%2Fapp%2Fpage.tsx%22%2C%22state%22%3A%22IDLE%22%7D%5D%2C%22id%22%3A%22clyg9bptg00023j6k3w4rphuo%22%2C%22activeTabId%22%3A%22clyga1kel00023j6jbbv43sut%22%7D%2C%22clyg9bptg00053j6kuo9qzs1s%22%3A%7B%22id%22%3A%22clyg9bptg00053j6kuo9qzs1s%22%2C%22tabs%22%3A%5B%7B%22type%22%3A%22UNASSIGNED_PORT%22%2C%22port%22%3A3000%2C%22id%22%3A%22clyg9yq6t00es3j6k6oy35ccs%22%2C%22mode%22%3A%22permanent%22%2C%22path%22%3A%22%2F%22%7D%5D%2C%22activeTabId%22%3A%22clyg9yq6t00es3j6k6oy35ccs%22%7D%2C%22clyg9bptg00043j6kmh0go18l%22%3A%7B%22id%22%3A%22clyg9bptg00043j6kmh0go18l%22%2C%22tabs%22%3A%5B%7B%22id%22%3A%22clyg9bptg00033j6k5zx5lc4f%22%2C%22mode%22%3A%22permanent%22%2C%22type%22%3A%22TASK_LOG%22%2C%22taskId%22%3A%22dev%22%7D%5D%2C%22activeTabId%22%3A%22clyg9bptg00033j6k5zx5lc4f%22%7D%7D%2C%22showDevtools%22%3Atrue%2C%22showShells%22%3Atrue%2C%22showSidebar%22%3Atrue%2C%22sidebarPanelSize%22%3A15%7D

To Reproduce

  1. npm run build && npm run start
  2. Visit root page /
  3. The ImageResponse will have a bogus Cache-Control header public, immutable, no-transform, max-age=31536000, max-age=3600, s-maxage=3600

Current vs. Expected behavior

Currently, ImageResponse merges the headers options while keeping all default headers instead of respecting the explicit overwrite from the developer. E.g., "{ headers: { 'Cache-Control': 'max-age=3600, s-maxage=3600' } }becomesCache-Control: public, immutable, no-transform, max-age=31536000, max-age=3600, s-maxage=3600`.

As an expected behavior, "{ headers: { 'Cache-Control': 'max-age=3600, s-maxage=3600' } }should becomeCache-Control: max-age=3600, s-maxage=3600`.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.62 // Latest available version is detected (15.0.0-canary.62).
  eslint-config-next: N/A
  react: 19.0.0-rc-6f23540c7d-20240528
  react-dom: 19.0.0-rc-6f23540c7d-20240528
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Not sure

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

next dev (local), next start (local), Vercel (Deployed)

Additional context

No response

@Luluno01 Luluno01 added the bug Issue was opened via the bug report template. label Jul 10, 2024
@Luluno01
Copy link
Contributor Author

When headers property is an instance of Headers, it is completely discarded. See #67642 (comment).

@Luluno01
Copy link
Contributor Author

Please review the PR. Just a few lines...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant