next.js
next.js copied to clipboard
Cookies cannot be read in middleware while defined in server actions (since 14 at least)
Link to the code that reproduces this issue
https://github.com/ScreamZ/reproduction-app-cookies-middleware
To Reproduce
- Start application
- Clic "click me" button
Current vs. Expected behavior
Cookies are set in Server action and middleware is not able to catch it!
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000
Available memory (MB): 32768
Available CPU cores: 10
Binaries:
Node: 20.11.1
npm: 10.2.4
Yarn: 1.22.19
pnpm: 9.12.1
Relevant Packages:
next: 15.0.0-canary.196
eslint-config-next: N/A
react: 19.0.0-rc-77b637d6-20241016
react-dom: 19.0.0-rc-77b637d6-20241016
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Middleware, Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
No response
See related post https://github.com/vercel/next.js/issues/71425 for additional use case
I'm facing the same problem on v15.0.1. I cannot see cookies when using headers() and cookies()