Accepted
Currently, MFE settings are set via command line environment variables or an .env file that is read during the build process, causing the operators to rebuild mfes each time when any variables are changed. The creation of the mfe_config_api
allows configuration at runtime and avoids rebuilds.
MFE Configuration during Runtime.
- A lightweight API will be created that returns the mfe configuration variables from the site configuration or django settings. PR Discussion about django settings
- The API will be enabled or disabled using the setting
ENABLE_MFE_CONFIG_API
. - The API will take the mfe configuration in the
MFE_CONFIG
keyset in the site configuration (admin > site configuration > your domain) or in django settings. - This API allows to consult the configurations by specific MFE. Making a request like
api/v1/mfe_config?mfe=mymfe
will return the configuration defined inMFE_CONFIG_MYMFE
merged with theMFE_CONFIG
configuration. - The API will have a mechanism to cache the response with
MFE_CONFIG_API_CACHE_TIMEOUT
variable. - The API will live in lms/djangoapps because this is not something Studio needs to serve and it is a lightweight API. PR Discussion
- The API will not require authentication or authorization.
- The API request and response will be like:
Request:
GET http://lms.base.com/api/v1/mfe_config?mfe=learning
Response:
{ "BASE_URL": "https://name_of_mfe.example.com", "LANGUAGE_PREFERENCE_COOKIE_NAME": "example-language-preference", "CREDENTIALS_BASE_URL": "https://credentials.example.com", "DISCOVERY_API_BASE_URL": "https://discovery.example.com", "LMS_BASE_URL": "https://courses.example.com", "LOGIN_URL": "https://courses.example.com/login", "LOGOUT_URL": "https://courses.example.com/logout", "STUDIO_BASE_URL": "https://studio.example.com", "LOGO_URL": "https://courses.example.com/logo.png" }
- We have to change all the mfes so that they take the information from the API. Issue MFE runtime configuration in frontend-wg
- Initialize the MFE could have a delay due to the HTTP method.
- Site configuration is going to be deprecated so later we have to clean the code that uses site configuration.
- The operator is responsible for configuring the settings in site configuration or django settings.
- We can have duplicate keys in site configuration (example: we can have a logo definition for each mfe).
- If the request is made from a domain that does not have a site configuration, it returns django settings.
- It was not made as a plugin or IDA because it is a lightweight implementation PR Discussion