Stale environment variable values when accessing from middleware #66962
Labels
bug
Issue was opened via the bug report template.
Middleware
Related to Next.js Middleware
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
Code sandbox
To Reproduce
.env.local
middleware.ts
, log it to the consolepage.ts
(must be a server component), log it to the console.env.local
Current vs. Expected behavior
Current behavior: Environment variables get stale on the middleware side when updating env var, as the value differs from the latest that can be accessed on the application side.
Expected behavior: Values must change on both sides, both being fresh. Currently, we're facing an issue, on this PR, where the same env var value is used for encryption on the middleware runtime and decryption on the application runtime, therefore those must be in sync, especially when developing locally.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030 Available memory (MB): 18432 Available CPU cores: 11 Binaries: Node: 20.12.2 npm: 10.5.0 Yarn: 1.22.22 pnpm: 9.2.0 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.4.5 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)
Additional context
No response
The text was updated successfully, but these errors were encountered: