Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale environment variable values when accessing from middleware #66962

Open
LauraBeatris opened this issue Jun 17, 2024 · 0 comments
Open

Stale environment variable values when accessing from middleware #66962

LauraBeatris opened this issue Jun 17, 2024 · 0 comments
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.

Comments

@LauraBeatris
Copy link
Contributor

LauraBeatris commented Jun 17, 2024

Link to the code that reproduces this issue

Code sandbox

To Reproduce

  • Define an environment variable on .env.local
  • Access it on middleware.ts, log it to the console
  • Access it on page.ts (must be a server component), log it to the console
  • Refresh page, see the logs
  • Update env var on .env.local
  • Refresh page, see the logs. Verify that the values aren't matching 👀

CleanShot 2024-06-17 at 15 10 50

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

@LauraBeatris LauraBeatris added the bug Issue was opened via the bug report template. label Jun 17, 2024
@github-actions github-actions bot added Middleware Related to Next.js Middleware Runtime Related to Node.js or Edge Runtime with Next.js. labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant