Differentiate between PROD and DEV variables

My ionic app is now tested in DEV/QA and it is ready to be sent to PRD.
Now, for Production, all my api base domains are different. So, i have to change it to PRD variables before sending it to PRD.

But, after that, whenever i do something new, i have to manually change it back again to DEV variables. What is the recommended way to handle this?


I do something like this in the base controller for my project:

$rootScope.DEVELOPMENT = true;
// Because my laptop has it's own server running on it
$rootScope.LAPTOP = false; 

$rootScope.server = 'https://domain.com';

if ($rootScope.LAPTOP) {
    $rootScope.server = 'https://local.domain.com';
} else if ($rootScope.DEVELOPMENT) {
    $rootScope.server = 'https://dev.domain.com';

$rootScope.apiURL = $rootScope.server + '/mobile-api';

In the above example, all of my API calls are going to the development server in the cloud. Whenever I’m going to make an API call I can use a generic URI that is ‘smart’…

$http.post($rootScope.apiURL + '/user/login.php', {
    email: // ...
    password: //...
}).then(/* */);

Really though, everyone has their own way of handling this problem. Hit up Google and find what works best for you.

1 Like