vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.88k stars 26.86k forks source link

Cookies cannot be read in middleware while defined in server actions (since 14 at least) #71425

Open ScreamZ opened 1 day ago

ScreamZ commented 1 day ago

Link to the code that reproduces this issue

https://github.com/ScreamZ/reproduction-app-cookies-middleware

To Reproduce

  1. Start application
  2. Clic "click me" button

Current vs. Expected behavior

Cookies are set in Server action and middleware is not able to catch it! image

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

ScreamZ commented 23 hours ago

See related post https://github.com/vercel/next.js/issues/71425 for additional use case