Source all environment variables in order to match Next
See original GitHub issue🐛 Bug Report
The library only loads environment variables when they’re prefixed with NEXT_PUBLIC_.
However, this is different than Next’s behavior. These “private” environment variables are indeed made available to SSR and build functions, such as getStaticProps.
Reproduction
Simply require an environment variable without a NEXT_PUBLIC_ prefix in a getStaticProps function, for example. It will be undefined.
Expected behavior
In order to match Next and expected functionality, these variables should be available to build and server runtime functionality.
Jest patch
Have you patched Jest as described here?
- yes
- no
Run npx envinfo --preset jest
Paste the results here:
System:
OS: Linux 5.11 Arch Linux
CPU: (20) x64 Intel(R) Core(TM) i9-7900X CPU @ 3.30GHz
Binaries:
Node: 15.9.0 - ~/.nvm/versions/node/v15.9.0/bin/node
npm: 7.5.3 - ~/.nvm/versions/node/v15.9.0/bin/npm
npmPackages:
jest: ^26.6.3 => 26.6.3
Thanks for your work on this very helpful test library.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
List all environment variables from the command line
To show certain variable such as 'PATH', use SET PATH . For help, type set /? . Share.
Read more >How To Read and Set Environmental and Shell Variables on ...
We can see a list of all of our environmental variables by using the env or printenv commands. In their default state, they...
Read more >An Introduction to Environment Variables and How to Use Them
Next, let's look at how to utilize environment variables using the native operating system, the NPM package dotenv, and webpack.
Read more >Next.js environment variables - Refine Dev
Basically, environment variables are added into Next.js apps through a env.local file. This will then load every variable into the Node.js ...
Read more >What are PATH and other environment variables, and how ...
What are Environment Variables? Environment variables hold values related to the current environment, like the Operating System or user sessions. Path.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The issue affected only
getStaticProps. It was an actual missing implementation detail 👍 Fixing with #197Hi @toomuchdesign, sorry for the delay. Thank you very much for your fix!