The way we configure all of our apps for deployment, where I work, is by using the standard pattern of a config
folder with a default config and then dev/staging/prod configs that can override this.
We are then passing in env values using the next.config.js
env
object.
Again - fairly standard way of doing things.
We use the Config library to pull data out of our config in order to populate the env
object. Nothing odd about this.
So, we have a config folder with:
default.json5 dev.json5 staging.json5 production.json5
The problem is, when next.js is run with next start
, it will always use production.json5
regardless of what NODE_ENV
we have set.
We're about to just bite the bullet and use a custom server, before we do, I thought I'd reach out to see if there's an obvious answer to this.
How to get next.js to respect the NODE_ENV
and not blindly just pull in a production
config on next start
?