Having different configuration options for testing and production environments

Hey All,

I would like to know, that is the standard ionic way of having different configurations for different environments.

For an example,

  • When I test my app, all the http requests in my Providers are pointing to my staging / local api end point.

  • When I go for production, those should be pointed to the production url endpoint.

I’m coming from a ruby/rails background and in rails we have basic 3 different environments (development / testing / production) to have different config options.

Just wanted to get an advise from more experience ppl than me :slight_smile:, thanks in advance.

cheers

Sam

ionicBootstrap(MyApp, [], { prodMode:  window.hasOwnProperty('cordova')});

With a bit of encapsulation, the same approach can be used in many places.

@itlr and later how do I detect the prodMode enabled inside my services?

@matheo you can put the state in a CONFIG obejct

const prod = window.hasOwnProperty('cordova');
export var CONFIG = {
  prod: prod
}

and inject or simply import the CONFIG object into where-ever needed

[Following approach is invalid]

or if you don’t want to use a separate config object or anything like that

I think injecting Platform should give you the passed in prodMode state.

import {Platform} from ... // see app.ts
class MyService {
  constructor (platform: Platform)
}