Manage urls in a system

1

I'm in a project where there's the test environment, and the production environment.

When I'm developing in test, I use a few different urls for this. I use some amazon services, which are different from production urls.

However, it is very annoying to get manually, changing the urls, I would like to know if there is any good practice to manage this.

    
asked by anonymous 09.12.2016 / 17:21

1 answer

1

You can check in the application what the environment is, whether you are in production or development.

With the expression it would look something like this:

var app = express();
if (app.get('env') === 'production') {
    // setar variáveis de produção
} else {
    // setar variáveis de desenvolvimento
}

In native Node.js it would be:

if (process.env.NODE_ENV === 'production') {
    // setar variáveis de produção
} else {
    // setar variáveis de desenvolvimento
}
    
09.12.2016 / 17:27