Skip to content

[NEXT-582] Unable to define multiple Set-Cookie headers via config headers #40518

Description

@awareness481

Verify canary release

  • 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

NEXT-582

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.linear: nextConfirmed issue that is tracked by the Next.js team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions