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

.env values override existing env vars when using --watch #558

Open
tandibar opened this issue Oct 14, 2022 · 0 comments
Open

.env values override existing env vars when using --watch #558

tandibar opened this issue Oct 14, 2022 · 0 comments

Comments

@tandibar
Copy link

If you start a fastify app with the fastify cli and the watch parameter, the environment variable precedence is changed.

Example

So if you have a .env file with

MY_ENV_VAR=foo

and you run

MY_ENV_VAR=bar fastify start app.js

then process.env.MY_ENV_VAR will be 'bar'. Perfect! But if you run it with the watch parameter like

MY_ENV_VAR=bar fastify start --watch app.js

then process.env.MY_ENV_VAR will be 'foo'.

Suggestion

I think it has something to do with this line of code.

tandibar added a commit to tandibar/fastify-cli that referenced this issue Oct 14, 2022
tandibar added a commit to tandibar/fastify-cli that referenced this issue Oct 15, 2022
tandibar added a commit to tandibar/fastify-cli that referenced this issue Nov 11, 2022
mcollina pushed a commit that referenced this issue Nov 14, 2022
…hen using --watch #558 (#564)

* fix: prevented .env values ​​from overwriting existing env values ​​when using --watch #558

* fix: prevented .env values ​​from overwriting existing env values ​​when using --watch #558

* test: world because when making a restart the server still passes the arguments that change the environment variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant