material-identity / schemas

0 stars 0 forks source link

[feat] UI should call api url dynamically depending on environment #55

Open anfern777 opened 17 hours ago

anfern777 commented 17 hours ago

Description

Currently the UI is explicitly pointing to the development server api. This behaviour should be changed so that it dynamically fetches the current environment and calls the corresponding api URL.

Expected Behaviour

local - api should call http://localhost:8081 development - api should call https://schemas-service.development.s1seven.com staging - api should call https://schemas-service.staging.s1seven.com production - api should call https://schemas-service.s1seven.com

anfern777 commented 17 hours ago

The solution I thought about consists on creating an angular configuration for each environment and build it using the env config as an argument. E.g. ng build --configuration staging. This would inject the env variable corresponding to the provided configuration into the angular app. Then, after build, we would copy the static assets into folder src/resources/static with an heroku cd script.

anfern777 commented 17 hours ago

For context: Spring Boot is serving static assets (the built SPA app) from src/resources/static. So currently the app is being built locally and its static files manually copied to this directory before deployment. The idea would be to dynamically build it based on the environment with the configuration arg.

Other suggestions welcome.

eamon0989 commented 17 hours ago

We already do something similar in this project in case it serves as inspiration: https://github.com/s1seven/dmp-explorer-poc/blob/main/set-env.js