vercel / vercel/next.js

Pages Router does not use updated cookies from Proxy `response.cookies.set()`, unlike App Router

Open
#90,202 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Middleware Pages Router
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://github.com/thomasboyt/nextjs-broken-pages-router-proxy-cookies-behavior

To Reproduce
  1. next dev
  2. Visit localhost:3000/app-demo. Notice that the new cookie value is displayed correctly in the rendered component.
  3. Clear your cookies.
  4. Visit localhost:3000/pages-demo. Notice that the new cookie value is not displayed correctly.
  5. Refresh. Notice the new cookie value is now displayed correctly.
Current vs. Expected behavior

The Pages Router should support the same behavior as App Router, as implemented in https://github.com/vercel/next.js/pull/65008: setting cookies using response.cookies.set() should show the new cookie values in ctx.req.cookies in getServerSideProps, as they show up in next/headers's cookies() function in App Router.

Otherwise, the documentation on https://nextjs.org/docs/pages/api-reference/file-conventions/proxy#using-cookies should be updated to indicate this is expected to not work in Pages Router.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 16
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.0-canary.51 // Latest available version is detected (16.2.0-canary.51).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Pages Router, Middleware

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

next dev (local), next start (local)

Additional context

This is blocking an incremental rewrite of my application in App Router. My application heavily used getServerSideProps and set various cookies in its logic. I am trying to move the logic that was used for all requests to proxy.ts, as App Router does not allow setting cookies during server-side rendering. Unfortunately, right now I cannot rely on proxy.ts cookie setting to work correctly in Pages Router.

I may have to implement a manual workaround using headers added to the request.

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

Run the linked reproduction with both /app-demo and /pages-demo, then compare the Proxy response.cookies.set() path with getServerSideProps and ctx.req.cookies in the Pages Router. Check the related App Router behavior from PR 65008. Done means updated cookie values are available in Pages Router requests, or the Pages Router cookie limitation is documented at the cited Proxy documentation page.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.