angular-environment
angular-environment copied to clipboard
Defaults block is not actually the default
According to the documentation, the 'defaults' block is supposed to be the catch-all area, however in testing it appears that 'development' is actually the catch-all section. Recommend fixing the code to make the 'defaults' block the catch-all area if there are no matches, or update the documentation to note that 'development' is the catch-all area if there are no matches.
I believe development
is the fallback if no other domains match. defaults
will still provide vars not specified in the detected environment.
You can change the fallback environment in the case where no domains match by calling set
before check
:
// set the domains and variables for each environment
envServiceProvider.config({
domains: {
development: ["localhost", "acme.dev.local"],
production: ["acme.com", "*.acme.com", "acme.dev.prod"],
test: ["test.acme.com", "acme.dev.test", "acme.*.com"],
// anotherStage: ['domain1', 'domain2']
},
vars: {
development: {
apiUrl: "//api.acme.dev.local/v1",
staticUrl: "//static.acme.dev.local",
// antoherCustomVar: 'lorem',
// antoherCustomVar: 'ipsum'
},
test: {
apiUrl: "//api.acme.dev.test/v1",
staticUrl: "//static.acme.dev.test",
// antoherCustomVar: 'lorem',
// antoherCustomVar: 'ipsum'
},
production: {
apiUrl: "//api.acme.com/v1",
staticUrl: "//static.acme.com",
// antoherCustomVar: 'lorem',
// antoherCustomVar: 'ipsum'
},
// anotherStage: {
// customVar: 'lorem',
// customVar: 'ipsum'
// },
defaults: {
apiUrl: "//api.default.com/v1",
staticUrl: "//static.default.com",
},
},
});
// default the environment to production
envServiceProvider.set('production')
// run the environment check, so the comprobation is made
// before controllers and services are built
envServiceProvider.check();