question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic environment variables undefined during SSR on Windows (*not* fixed by #5955)

See original GitHub issue

Describe the bug

I already mentioned it in https://github.com/sveltejs/kit/issues/5941#issuecomment-1221102524 but it might get lost.

On Windows, the env-export of $env/dynamic/private and $env/dynamic/public is always an empty object.

This issue was present on Linux, too, but #5955 apparently fixed it there (available since next.418). It did not, however, fix it for Windows.

Related: #5941, #5955

Reproduction

Repro https://github.com/validData/kit-env-issues The repo should be rather self explanatory - the page uses private and public, dynamic and static environment variables. Static environment variables work fine both on Windows and Linux, dynamic variables only work fully on Linux. On Windows, all server side dynamic variables are missing. On the client side, they work fine (though not shown here - hydration is deactivated)

Running on WSL: image

Running on Windows: image

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 10.60 GB / 31.81 GB
  Binaries:
    Node: 16.15.1 - c:\tools\node\node.EXE
    Yarn: 1.22.19 - c:\tools\node\yarn.CMD
    npm: 8.13.2 - c:\tools\node\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.63)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.65
    @sveltejs/kit: next => 1.0.0-next.428
    svelte: ^3.44.0 => 3.49.0
    vite: ^3.0.4 => 3.0.9

Severity

blocking an upgrade

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Kraftwurmcommented, Aug 31, 2022

I have the same problem. Windows, and the $env/dynamic/private is always empty. I’m on : @sveltejs/kit@1.0.0-next.431

Update: Works for me too now on : @sveltejs/kit@1.0.0-next.459

0reactions
DoisKohcommented, Aug 31, 2022

Thanks, I’ve confirmed that it’s fixed for me as well on @sveltejs/kit@1.0.0-next.456.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic environment variables undefined during SSR on ...
This issue was present on Linux, too, but #5955 apparently fixed it there (available since next.418). It did not, however, fix it for...
Read more >
Consistent handling of environment variables #4296 - GitHub
Environment variables can be static (known at build time) or dynamic (not known until run time), and private (only accessible to code that ......
Read more >
NextJS environment variables are undefined in the client-side ...
Event with having prefixed all client-side exposed variables with NEXT_PUBLIC verifying them results in error. The server-side does not complain ...
Read more >
Using environment variables - Astro Documentation
Learn how to use environment variables in an Astro project.
Read more >
Env Variables and Modes - Vite
For example, dynamic key access like import.meta.env[key] will not work. It will also replace these strings appearing in JavaScript strings and Vue templates....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found