Correct way to access current application configuration

前端 未结 3 731
一整个雨季
一整个雨季 2021-02-05 10:39

I added some configurations to myapp/config/environment:

if (environment === \'development\') {
  ENV.APP.AuthURL = \'http://localhost:5000/\';
}
         


        
3条回答
  •  难免孤独
    2021-02-05 11:12

    While @rog's answer is correct and will work for all cases where you are trying to access the config from your application there are some edge cases (such as accessing config from an addon) that it will not work for.

    I would recommend checking out the ember-get-config addon: https://www.emberobserver.com/addons/ember-get-config

    Once you install ember-get-config you can import your config using the following code:

    import config from 'ember-get-config';
    const { AuthURL } = config;
    // now you have access to AuthURL 

提交回复
热议问题