-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Description
Link to the code that reproduces this issue
https://github.com/thomasboyt/nextjs-broken-pages-router-proxy-cookies-behavior
To Reproduce
next dev- Visit
localhost:3000/app-demo. Notice that the new cookie value is displayed correctly in the rendered component. - Clear your cookies.
- Visit
localhost:3000/pages-demo. Notice that the new cookie value is not displayed correctly. - 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 #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/AWhich 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.