Home > database >  How to see process.env after starting server
How to see process.env after starting server

Time:07-01

I am developing sample apps and would like to know process.env variables, I know console.log(process.env) will return its variables. But can I see them after run its server ?

npm start

I couldn't input anything in console. As I am new to node.js, will you please let me know. by switing NODE_ENV, it seems that development,staging,production is switched. So that I would like to comfirm them.

Thanks

CodePudding user response:

If you start your server in docker and don't pass custom variables to process.env in your app, you can see your env by docker command:

docker exec your_container env

Yet another way - create a specific route in your application that will be return you all data from process.env.

Something like this:

GET yourserver/api/system/env

But this way is not secured and you should think about protection of your system route.

UPD

Also you can call console.log(process.env) after server has been started.

await app.listen(3000);
console.log(process.env);
  • Related