How to handle different environments in App Connect?

I’m trying to work out how to configure settings differently between environments on the client side, as you would using .env files in Node.

Ideally, it would be a series of settings applied at the project level, per target environment, which allows us to set things like API parameters (domain, port, http/s, api version in the URL, etc), which we could then use in the various dynamic parameters parts of Wappler.

It also means when we migrate from dev to the higher environments, we don’t need to keep updating the URL every place it’s found.

Any idea how this can be done?


1 Like

OK, I’ve got something working that will cover my needs, which is basically an API change per environment.

  1. in the project directory, run ‘npm install --save dotenv’
  2. edit /index.js in the project directory, add this line at the top:


  1. Create the .env file at the top leve of the project directory, as per instructions for dotenv.

  2. In places where you need the env var, use

<%- $_ENV.x %>

where x is the name of the variable from the.env file.

I’m using this in the URL of App Connect API calls, and it’s working fine.

Hope that helps,

You need to take into account that index.js will get overwritten with Wappler updates. So you need to redo with every update. Easy if you are using GIT.

Thanks Jon, understood. Thanks for pointing that out for others however.

I’m hoping #TeamWappler pick this up and include it in the core template…


I should also add a note for the non-developers here that this is a solution for a node backend. It obviously won’t work for PHP/ASP.


Hello, I’ve started using dotenv. Thanks a lot for the detailed steps.

In addition, I have some recommendations on how to use it for db settings.

Just to recap the specific steps I followed:

  1. Use the syntax: {{$_ENV.varName}} ej. {{$_ENV.pg_host}} directly in the UI or directly on code:


*it works with strings.
It would be handy for setting Server Connect Debug Mode = true/false, but apparently env variables can’t return boolean values when called within a json file. (maybe I’m wrong)

With the last update we included dotenv by default. Environment variables can only contain strings, that is a limitation they have.

I have attempted to write a solution for php/apache here.

Environment Variables are now available in Wappler 4.9.0 UI:

This topic was automatically closed after 2 days. New replies are no longer allowed.