My goal is to use the same angular build in multiple environments(dev,qa,prod). In my code I'm accessing a few rest api`s. As you can already understand, the hostname in the url is different between the environments..
I have seen multiple solution online and I got a question regarding one specific solution that is described in the following article : Host configurations as assets — mount configuration files per environment :
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {shareReplay} from 'rxjs/operators';
interface Configuration {
resourceServerA: string;
resourceServerB: string;
stage: string;
}
@Injectable({providedIn: 'root'})
export class ConfigAssetLoaderService {
private readonly CONFIG_URL = 'assets/config/config.json';
private configuration$: Observable<Configuration>;
constructor(private http: HttpClient) {
}
public loadConfigurations(): any {
if (!this.configuration$) {
this.configuration$ = this.http.get<Configuration>(this.CONFIG_URL).pipe(
shareReplay(1)
);
}
return this.configuration$;
}
}
Lets assume that I used this solution and there is a dedicated service that loads the config.json file from the filesystem. I deployed a docker image of my app into a docker container (with nginx). When the app starts I load a file from filesystem right ? Well this is the part that I'm missing. My app is a frontend app, so wouldnt the service run on the customers browser try to load the config file from the customers side ?