Update to have a configuration file out of the

app bundle.
This commit is contained in:
Sébastien André
2021-02-03 10:57:30 +01:00
parent 9a9dc3fbea
commit 671f02f440
18 changed files with 99 additions and 34 deletions
@@ -1,18 +1,32 @@
import { Injectable } from '@angular/core';
import { Injector } from '@angular/core';
import { HttpHeaders } from '@angular/common/http';
import { environment } from '../environments/environment';
import { ConfigurationHelper } from './configuration-helper';
@Injectable()
export class BaseService {
protected readonly headers: HttpHeaders;
protected readonly apiUrl: string;
protected headers: HttpHeaders;
protected apiUrl: string;
constructor() {
this.headers = new HttpHeaders({
'Access-Control-Allow-Origin': environment.apiUrl
ConfigurationHelper.settings.subscribe(settings =>
{
let tmpApiUrl : string = settings.apiUrl;
this.headers = new HttpHeaders({
'Access-Control-Allow-Origin': tmpApiUrl
});
this.apiUrl = tmpApiUrl + '/api';
});
this.apiUrl = environment.apiUrl + '/api';
// const config: ConfigurationHelper = injector.get(ConfigurationHelper);
// config.load(environment.env)
// .then(() => {
// let tmpApiUrl : string = ConfigurationHelper.settings.apiUrl;
// this.headers = new HttpHeaders({
// 'Access-Control-Allow-Origin': tmpApiUrl
// });
// this.apiUrl = tmpApiUrl + '/api';
// });
}
}