-
Notifications
You must be signed in to change notification settings - Fork 12k
Store config in the environment (ENV) #29447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is (partially) being discussed in #28661, with the distinction that this issue approaches is from an SSR/SSG perspective. |
environment.ts can have functions, not only constants. It's just a TS file, use whatever you want there. |
This is essentially a duplicate of angular/angular#58433 When the configuration is fetched on the server side using |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/related to the feature request?
compiler
Description
Current solutions
We have several options to add configuration into a Angular application
environment.ts
and add the configuration during the build fase,/assets/config.json
and fetch the configuration during the initialization of the application (which can go wrong, etc).All these solutions have a con and that is it can't change the configuration during deployment of the application.
Which is bad because its violates the guideline
III. Config
ofThe Twelve-Factor App
.The Twelve-Factor App (https://12factor.net/)
As a developer we want to follow these guidelines so the app can be deployed in several ways on several systems.
III. Config - Store config in the environment
As you can read the
environment.ts
solution violates this rulestore config as constants in the code
(but I like that the config is build into the application).So why don't want I use the
/assets/config.json
solution? Because;Solution
I would like to see a solution which provides a way to add the configuration during the deployment of the server in the environment as the
III. Config - Store config in the environment
rule suggests.Proposed solution
Inspired by the working of the Angular TransferState
environment
-element in the index.html during startup, andenvironment
-element is parsed an can be used as configuration.During development a default configuration is used.
Alternatives considered
Always compile the
environment.ts
in a separated file, in a predictable format, so we can change the values during startup of the web server.The text was updated successfully, but these errors were encountered: