next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Unable to define multiple Set-Cookie headers via config headers

Open awareness481 opened this issue 3 years ago • 0 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:42 PST 2022; root:xnu-7195.141.26~1/RELEASE_ARM64_T8101
Binaries:
  Node: 16.15.1
  npm: 8.19.1
  Yarn: N/A
  pnpm: 7.6.0
Relevant packages:
  next: 12.3.1-canary.1
  eslint-config-next: 12.3.0
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

It is impossible to define multiple Set-Cookie headers, via next.config.js/headers. Next.js seems to only account for the last defined Set-Cookie header for a given path

Expected Behavior

Based on the rfc I would expect to be able to define multiple Set-Cookie headers and for the headers to not be combined into one header. (they re not combined atm, only the last header is used)

Link to reproduction

https://github.com/awareness481/next-config-cookies

To Reproduce

  1. See that next.config.js has two Set-Cookie headers for each route
  2. Visit http://localhost:3000/1 and observe that only one cookie is defined
  3. Visit http://localhost:3000/2 and observe that only one cookie is defined

awareness481 avatar Sep 13 '22 13:09 awareness481