How to change to a production environment in ACE cloud add-on using Node.js

Hello everyone. I developed a cloud addon with ACE and Node.js in development environment using ngrok which worked perfectly on a local machine. Now I want to test the addon which is set on a https server. Should I change the environment to production or can I use the development environment but without the ngrok tunneling, and how it would be? Thank you

Hi @Ivana1 ,

To test in your production environment, you probably wouldn’t want to be using ngrok and auto registering. I’d recommend using the production settings of your config.json. On the assumption you’ve configured the production settings to use a real data store rather than memory, then it shouldn’t be self registering unless you’ve overridden the force-reg option.

Regards,
Dugald

Than you @dmorrow for the response,
but can I install the addon which is served on my own https server, and still using development environement from the config.json file, with disabled ngrok tunneling and auto-registration somehow?

Hi @Ivana1 ,

I think this is possible. Have you seen the atlassian-connect-express documentation?

Regards,
Dugald

Hi @Ivana1,

Yes, you can certainly do that. As @dmorrow rightly points out, you can use config.json to define various settings. And while the default uses environments like development and production, you can also define additional environments to suit your needs, like dev-test or dev-without-auto-reg.

As an additional recommendation, you should use something like dotenv to control which environment the application runs in.

Hope that helps,
Oliver

1 Like

Thank you @osiebenmarck ,
How can I define an environment like dev-without-auto-reg?

Hi @Ivana1 ,

it’s really easy, just add it to config.json like this:

{
    "development": {
        "localBaseUrl": "$BASEURL",
        "port": 3000,
        "errorTemplate": true,
        "store": {
            "adapter": "sequelize",
            "dialect": "postgres",
            "url": "$DATABASE_URL"
        }
    },
    "dev-without-auto-reg": {
        "port": 3000,
        "errorTemplate": true,
        "localBaseUrl": "$BASEURL",
        "store": {
            "type": "postgres",
            "url": "$DATABASE_URL"
        }
    },
  ... // More environments
}

Now, the more interesting part is using dotenv, which allows you define a environment variables pretty easily. Here’s how that might look like:

AC_OPTS=no-reg
NODE_ENV=dev-without-auto-reg
BASEURL=https://my-cool-app.dev-test.com
DATABASE_URL=postgres://user:pass@somewhere

Personally, I then start my app with node -r esm -r dotenv/config src/app.js which tells dotenv to load the environment variables from the .env file. If you want to use a different environment, simply edit the .env file.

Hope that helps,
Oliver

1 Like