Open cusxio opened 4 days ago
https://github.com/cusxio/next-middleware-test
Source
Right now, there's a difference in behavior when setting headers in the middleware between the local edge runtime and production (hosted on Vercel's) edge runtime.
Here's an example of the production link: https://next-middleware-test-seven.vercel.app/
Noticed that the sessionId is null, however, if you run it locally, you can see that the sessionId is displayed.
sessionId
The behavior of setting headers should be consistent between Vercel and local development. It took me a while to realized that this was the problem.
Node.js v22.3.0 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.5.0: Wed May 1 20:17:33 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6031 Available memory (MB): 65536 Available CPU cores: 16 Binaries: Node: 22.3.0 npm: 10.8.1 Yarn: N/A pnpm: 8.15.5 Relevant Packages: next: 14.2.4 // Latest available version is detected (14.2.4). eslint-config-next: 14.2.4 react: 18.3.1 react-dom: 18.3.1 typescript: 5.5.2 Next.js Config: output: N/A
Middleware, Runtime
next dev (local), next start (local), Vercel (Deployed)
No response
Link to the code that reproduces this issue
https://github.com/cusxio/next-middleware-test
To Reproduce
Source
Description
Right now, there's a difference in behavior when setting headers in the middleware between the local edge runtime and production (hosted on Vercel's) edge runtime.
Here's an example of the production link: https://next-middleware-test-seven.vercel.app/
Noticed that the
sessionId
is null, however, if you run it locally, you can see that thesessionId
is displayed.Current vs. Expected behavior
The behavior of setting headers should be consistent between Vercel and local development. It took me a while to realized that this was the problem.
Provide environment information
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), Vercel (Deployed)
Additional context
No response