Skip to content

Commit 661e343

Browse files
committed
feat: fetch config from /config.json instead of /api/config
- Change ConfigService to fetch from nginx-served /config.json - Remove Authorization header (not needed for static file) - Config now comes from nginx ConfigMap instead of eagle-api - Preserves KEYCLOAK_CLIENT_ID as before (eagle-admin-console) - Enables instant config updates via ConfigMap edit
1 parent a47e4a3 commit 661e343

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/app/services/config.service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable, inject, signal, computed } from '@angular/core';
2-
import { HttpClient, HttpHeaders } from '@angular/common/http';
2+
import { HttpClient } from '@angular/common/http';
33
import { firstValueFrom, timeout } from 'rxjs';
44

55
interface EnvConfig {
@@ -122,7 +122,7 @@ export class ConfigService {
122122
}
123123

124124
/**
125-
* Fetch configuration from API endpoint.
125+
* Fetch configuration from nginx-served JSON.
126126
* Only called when configEndpoint=true (deployed environments).
127127
* Retries with fibonacci backoff, times out to prevent blocking.
128128
*/
@@ -135,27 +135,27 @@ export class ConfigService {
135135

136136
while (attempts < maxAttempts) {
137137
try {
138-
const headers = new HttpHeaders().set('Authorization', 'config');
139-
// Always use relative path - nginx routes to API in deployed env
138+
// Fetch config from nginx-served ConfigMap JSON
139+
// No Authorization header needed - public static file
140140
const response = await firstValueFrom(
141-
this.httpClient.get<any>('/api/config', { headers, observe: 'response' })
141+
this.httpClient.get<EnvConfig>('/config.json', { observe: 'response' })
142142
.pipe(timeout(requestTimeoutMs))
143143
);
144-
return response.body?.data || response.body || {};
144+
return response.body || {};
145145
} catch (err) {
146146
attempts++;
147147
if (attempts >= maxAttempts) {
148-
console.warn(`ConfigService: API config failed after ${maxAttempts} attempts`);
148+
console.warn(`ConfigService: Config fetch failed after ${maxAttempts} attempts`);
149149
throw err;
150150
}
151-
console.warn(`ConfigService: API config attempt ${attempts}/${maxAttempts} failed, retrying...`);
151+
console.warn(`ConfigService: Config fetch attempt ${attempts}/${maxAttempts} failed, retrying...`);
152152
const delay = n1 + n2;
153153
await this.delay(delay * 1000);
154154
n1 = n2;
155155
n2 = delay;
156156
}
157157
}
158-
throw new Error('Failed to load config from API');
158+
throw new Error('Failed to load config from /config.json');
159159
}
160160

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

0 commit comments

Comments
 (0)