1

I would like to configure a URL differently in my ember app depending if the app is running in production or development mode. Is this possible to do by loading the endpoints into config/environment.js and accessing the value of the ENV object in a handlebars template? Maybe I have to expose the ENV value in a controller? Or is there some other mechanism for doing this?

Something like this:

// config/environment.js

if (environment === 'development') {
  ENV.zzz.url = "http://www.reddit.com";
}

if (environment === 'production') {
  ENV.zzz.url = "http://www.google.com";
}

// app/controllers/application.js

export default Ember.Controller.extend({
  siteUrl: ENV.zzz.url
  ...

// somefile.hbs

<a href="{{siteUrl}}">Funspot</a>
gards
  • 555
  • 1
  • 6
  • 18
  • 1
    Happened to dig up this after the fact, which essentially is a more detailed version of below. https://stackoverflow.com/questions/29323852/correct-way-to-access-current-application-configuration – gards Jun 01 '17 at 19:10

1 Answers1

0

yes. you can do import config from 'app-name/config/environment'; and access it like config.zzz.url

Ember Freak
  • 12,918
  • 4
  • 24
  • 54