env.development has precedence over env.local
- Dominant language
- TypeScript
- Stars
- 14.1k
- Forks
- 803
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
Blitz being a framework on top of next js, I think it should behave very similar in standard functionality such as environment configuration. However there is currently a big difference in the order in which environment variables are loaded.
Imagine you have the following files
.env.local
`FAVORITE_COLOR=green`
.env.development
`FAVORITE_COLOR=red`
At runtime when running on next with `next dev` the value of `FAVORITE_COLOR` will be `green` because naturally your local config via `.env.local` has precedence over the default development config via `.env.development`, see [docs](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables#environment-variable-load-order). However if you run this with blitz via `blitz dev`, `FAVORITE_COLOR` will be `red`. I would highly recommend sticking to the next js order of loading env vars! what do you think?
```
Blitz version: 2.1.3 (local)
Linux 6.8 | linux-x64 | Node: v20.16.0
Package manager: npm
System:
OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
Memory: 17.36 GB / 27.23 GB
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 20.16.0 - /tmp/yarn--1732804901444-0.5375225702750697/node
Yarn: 1.22.22 - /tmp/yarn--1732804901444-0.5375225702750697/yarn
npm: 10.4.0 - ~/workbench/krisenchat/krisenchat/node_modules/.bin/npm
npmPackages:
@blitzjs/auth: 2.1.3 => 2.1.3
@blitzjs/next: 2.1.3 => 2.1.3
@blitzjs/rpc: 2.1.3 => 2.1.3
@prisma/client: 5.22.x => 5.22.0
blitz: 2.1.3 => 2.1.3
next: 14.2.13 => 14.2.13
prisma: 5.22.0 => 5.22.0
react: ~18.3.1 => 18.3.1
react-dom: ~18.3.1 => 18.3.1
typescript: 5.6.3 => 5.6.3
```
Contributor guide
Assessment
This issue has not been assessed yet.