GluuFederation / flex

Janssen + AdminUI + Casa
22 stars 13 forks source link

feat(admin-ui): injecting env properties dynamically in admin-ui built #1720

Closed duttarnab closed 1 month ago

duttarnab commented 1 month ago

The VM/CN installer is not running the npm i or npm run api commands. Instead, it is taking the dependencies and OpenAPI client from https://jenkins.gluu.org/npm/admin_ui/main/, which are generated during the Jenkins build. I think we can have Jenkins create the admin-ui build and place it at https://jenkins.gluu.org/npm/admin_ui/**. This will remove the responsibility of Flex installers to run the npm run build:prod command and hence will solve the long build time problem.

  1. create env-config.js in the root directory admin-ui project with the following contents.
const CONFIG_API_BASE_URL = "https://%(hostname)s/jans-config-api"
const API_BASE_URL = "https://%(hostname)s/jans-config-api/admin-ui"
const BASE_PATH = "/admin/"

window.configApiBaseUrl = CONFIG_API_BASE_URL
window.apiBaseUrl = API_BASE_URL
window.basePath = BASE_PATH
  1. Add <script src="/adminui-config.js" defer></script> in /admin-ui/app/index.html.
  2. Make changes in Admin UI project so that it takes the properties from env-config.js.
duttarnab commented 1 month ago

Reopening to remove BASE_PATH in env-config.js. It is essential to provide this property in .env so it cannot be altered using env-config.js.