NODE_ENV - Staging

Hello all!

I have my staging server set as:

To get the server usage, I created an action:

When running the action on staging server, I get this:

What do I have to change in order to show “staging” instead of “production”?

Many thanks!

Otavio

no one? @Teodor, @George? :smiley: Thanks guys!

I think the production is correct, with staging you want to test how the app would behave in production environment without any debugging and with all optimizations like caching.

There are also some problems when you would set it to staging, like described in following articles.

1 Like

Thanks @patrick! I have some emails routines that can’t be sent to “real users” on staging server, so I would like to check the target to set email to MailTrap if the app is running on staging. How can I approach this?

I too was a bit confused at first. But then it struck me… like Patrick says, staging is supposed to mimic production & not development.
We use environment variables extensively to manage things like not sending emails to customers when running the app on staging server.
All our targets - development, staging & production have different environment variables.

Where you set the env variables? Need to install an external lib? Thanks @sid!

I have docker based setup.
So I have created .env files for all three targets in the .wappler folder, next to their respoective yml files… then added a path of that in each target’s yml file.

env_file:
      - production.env

We also use a Caprover deplolyment where we set environment variable in the Caprover UI, and in Wappler just use .env file in root folder for local development.

2 Likes

Perfect @sid!

I created an enviroment.env file on the same folder of docker compose .yml file (wappler/targets/[target_name]), inside of this file, I created an env variable:

ENVIROMENT_NAME=PRODUCTION

On docker composer file, below “web” :

web:
env_file:
- enviroment.env

On server action, created a variable under $_ENV with the same name “ENVIROMENT_NAME” and now I can check what target is being used!

Thanks @sid!

2 Likes