vercel / vercel/next.js

Cookie header encoding

Open
#76,794 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Cookies
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/interesting-babbage-2lwwy5

To Reproduce

open preview in new window
refresh page to ensure cookie is set
see log in terminal

Current vs. Expected behavior

Current - user_name=John%2FDoe
Expected - user_name=John/Doe

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): 4242
  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.2.2-canary.0 // Latest available version is detected (15.2.2-canary.0).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  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)

Additional context

Now i need to do:

const requestHeaders = Object.fromEntries(headersList.entries());
if (requestHeaders.cookie) {
    requestHeaders.cookie = decodeURIComponent(requestHeaders.cookie);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction, open the preview in a new window, refresh to set the cookie, and inspect the terminal log. Trace how the next dev server reads and logs the cookie header; done means the slash remains unencoded without requiring decodeURIComponent in the user's request-header handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.