Skip to content

Commit 6f40547

Browse files
committed
refactor: fetch config from /api/config (nginx-served)
- Update ConfigService to fetch from /api/config instead of /config.json - Remove unused Helm env vars from values.yaml and values-prod.yaml - Angular apps don't read container env vars, config comes from /api/config Config served by nginx from rproxy-config ConfigMap.
1 parent f53499c commit 6f40547

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

helm/eagle-admin/values-prod.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ podDisruptionBudget:
2121
minAvailable: 1
2222

2323
# Mount existing ConfigMap for env.js
24-
# IMPORTANT: ConfigMap should only contain configEndpoint=true and KEYCLOAK_CLIENT_ID
25-
# All other config comes from /api/config. See wiki: Configuration-Management
24+
# Contains configEndpoint=true and KEYCLOAK_CLIENT_ID
25+
# All other config comes from /api/config (served by nginx from rproxy-config ConfigMap)
2626
envJs:
2727
configMap: "eagle-admin-env-js"
28-
29-
env:
30-
DEPLOYMENT_ENVIRONMENT: "prod"
31-
BANNER_COLOUR: ""
32-
REMOTE_API_PATH: "https://projects.eao.gov.bc.ca/api"
33-
REMOTE_PUBLIC_PATH: "https://projects.eao.gov.bc.ca/"

helm/eagle-admin/values.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,14 @@ probes:
5252
failureThreshold: 3
5353

5454
# Environment variables passed to the container
55-
env:
56-
RealIpFrom: "172.51.0.0/16"
57-
AdditionalRealIpFromRules: ""
58-
IpFilterRules: "#allow all; deny all;"
59-
DEPLOYMENT_ENVIRONMENT: ""
60-
BANNER_COLOUR: ""
61-
REMOTE_API_PATH: ""
62-
REMOTE_PUBLIC_PATH: ""
63-
KEYCLOAK_CLIENT_ID: "eagle-admin-console"
55+
# Container environment variables (optional, not used by Angular)
56+
# Angular reads config from /api/config, not container env vars
57+
env: {}
6458

6559
# env.js ConfigMap - mount external ConfigMap to override built-in env.js
6660
# Set configMap name to use existing ConfigMap, leave empty to use container's built-in env.js
67-
# IMPORTANT: Only set configEndpoint=true and KEYCLOAK_CLIENT_ID in this ConfigMap
68-
# All other config comes from /api/config. See wiki: Configuration-Management
61+
# ConfigMap should only contain: configEndpoint=true and KEYCLOAK_CLIENT_ID
62+
# All other config fetched at runtime from /api/config (served by nginx from rproxy-config)
6963
envJs:
7064
configMap: "" # e.g., "eagle-admin-env-js"
7165

src/app/services/config.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ export class ConfigService {
122122
}
123123

124124
/**
125-
* Fetch configuration from nginx-served JSON.
125+
* Fetch configuration from /api/config.
126126
* Only called when configEndpoint=true (deployed environments).
127+
* nginx serves this from ConfigMap (no eagle-api dependency).
127128
* Retries with fibonacci backoff, times out to prevent blocking.
128129
*/
129130
private async getConfigFromApi(): Promise<EnvConfig> {
@@ -135,10 +136,10 @@ export class ConfigService {
135136

136137
while (attempts < maxAttempts) {
137138
try {
138-
// Fetch config from nginx-served ConfigMap JSON
139-
// No Authorization header needed - public static file
139+
// Fetch config from nginx-served ConfigMap
140+
// No Authorization header needed - public endpoint
140141
const response = await firstValueFrom(
141-
this.httpClient.get<EnvConfig>('/config.json', { observe: 'response' })
142+
this.httpClient.get<EnvConfig>('/api/config', { observe: 'response' })
142143
.pipe(timeout(requestTimeoutMs))
143144
);
144145
return response.body || {};
@@ -155,7 +156,7 @@ export class ConfigService {
155156
n2 = delay;
156157
}
157158
}
158-
throw new Error('Failed to load config from /config.json');
159+
throw new Error('Failed to load config from /api/config');
159160
}
160161

161162
private delay(ms: number): Promise<void> {

0 commit comments

Comments
 (0)